Skip to content
Snippets Groups Projects
Advanced_2_wheeled_robot_4.blockly 22.85 KiB
<xml xmlns="https://developers.google.com/blockly/xml" version="15">
  <variables>
    <variable id="b(28E~2Ue!t~YD6isCAk">speed</variable>
    <variable id="FI;HT?u`GmEpXC~nKAUD">directions</variable>
  </variables>
  <block type="procedures_defnoreturn" id="NiWLdwSO2NgSRH~??)t_" x="123" y="-799">
    <mutation>
      <arg name="speed" varid="b(28E~2Ue!t~YD6isCAk" argid="ZLY4ZaxsoEy=biXA/{u,"/>
    </mutation>
    <field name="NAME">backward</field>
    <field name="ZLY4ZaxsoEy=biXA/{u,">speed</field>
    <statement name="STACK">
      <block type="motor_set_speed" id="JRSo^x/;PB;;)D2/d)JT">
        <field name="instance_name">F{dqcdhfNR!daaA/Amcp-SD/n[+bi,BfGY~A=zm:W</field>
        <field name="direction">Motor.CW</field>
        <value name="speed">
          <shadow type="motor_number" id="gP@MVA-=%i8O7[-e7H_%">
            <field name="MOTOR_NUM">512</field>
          </shadow>
          <block type="variables_get" id="W8,%3!hA!fPQ(*9;aZYZ">
            <field name="VAR" id="b(28E~2Ue!t~YD6isCAk">speed</field>
          </block>
        </value>
        <next>
          <block type="motor_set_speed" id=")fJWgX:Qv#nkR}zgYn=_">
            <field name="instance_name">F{dqcdhfNR!daaA/Amcp-Kfl.c){Uc6NV*s@jGRWn</field>
            <field name="direction">Motor.CW</field>
            <value name="speed">
              <shadow type="motor_number" id="doj90ul6[x;_;H4(2B6R">
                <field name="MOTOR_NUM">512</field>
              </shadow>
              <block type="variables_get" id="VS@OYG$aJhG~Ee5@#3d{">
                <field name="VAR" id="b(28E~2Ue!t~YD6isCAk">speed</field>
              </block>
            </value>
          </block>
        </next>
      </block>
    </statement>
  </block>
  <block type="procedures_defnoreturn" id="22bxHkMy$Ym,Z]CJJ}no" x="-391" y="-768">
    <mutation>
      <arg name="speed" varid="b(28E~2Ue!t~YD6isCAk" argid="ZLY4ZaxsoEy=biXA/{u,"/>
    </mutation>
    <field name="NAME">forward</field>
    <field name="ZLY4ZaxsoEy=biXA/{u,">speed</field>
    <statement name="STACK">
      <block type="motor_set_speed" id="418{(I+U]/Zh*6`6!HWZ">
        <field name="instance_name">F{dqcdhfNR!daaA/Amcp-SD/n[+bi,BfGY~A=zm:W</field>
        <field name="direction">Motor.CCW</field>
        <value name="speed">
          <shadow type="motor_number" id="gP@MVA-=%i8O7[-e7H_%">
            <field name="MOTOR_NUM">512</field>
          </shadow>
          <block type="variables_get" id="ZjehhPevN{Y*ZuQstl!k">
            <field name="VAR" id="b(28E~2Ue!t~YD6isCAk">speed</field>
          </block>
        </value>
        <next>
          <block type="motor_set_speed" id="SK@RFFQO:Nc!QZ#ii;;/">
            <field name="instance_name">F{dqcdhfNR!daaA/Amcp-Kfl.c){Uc6NV*s@jGRWn</field>
            <field name="direction">Motor.CCW</field>
            <value name="speed">
              <shadow type="motor_number" id="doj90ul6[x;_;H4(2B6R">
                <field name="MOTOR_NUM">512</field>
              </shadow>
              <block type="variables_get" id="HPZ3R,o|=y#K02Gz+(G!">
                <field name="VAR" id="b(28E~2Ue!t~YD6isCAk">speed</field>
              </block>
            </value>
          </block>
        </next>
      </block>
    </statement>
  </block>
  <block type="procedures_defnoreturn" id="hy)3xFtOdR-Ek;zg(u;R" x="-389" y="-590">
    <field name="NAME">turn_left</field>
    <statement name="STACK">
      <block type="motor_set_speed" id="GTc67r@A]O_lEutY`HfH">
        <field name="instance_name">F{dqcdhfNR!daaA/Amcp-SD/n[+bi,BfGY~A=zm:W</field>
        <field name="direction">Motor.CW</field>
        <value name="speed">
          <shadow type="motor_number" id="gP@MVA-=%i8O7[-e7H_%">
            <field name="MOTOR_NUM">250</field>
          </shadow>
        </value>
        <next>
          <block type="motor_set_speed" id="Ux8NP,Tw_$fT$@]hn,4`">
            <field name="instance_name">F{dqcdhfNR!daaA/Amcp-Kfl.c){Uc6NV*s@jGRWn</field>
            <field name="direction">Motor.CCW</field>
            <value name="speed">
              <shadow type="motor_number" id="doj90ul6[x;_;H4(2B6R">
                <field name="MOTOR_NUM">250</field>
              </shadow>
            </value>
          </block>
        </next>
      </block>
    </statement>
  </block>
  <block type="procedures_defnoreturn" id="-Fb2/$UM%/*M!+zbOgFw" x="151" y="-560">
    <field name="NAME">turn_right</field>
    <statement name="STACK">
      <block type="motor_set_speed" id="7k9]}=L%/`(m$7#`wkp9">
        <field name="instance_name">F{dqcdhfNR!daaA/Amcp-SD/n[+bi,BfGY~A=zm:W</field>
        <field name="direction">Motor.CCW</field>
        <value name="speed">
          <shadow type="motor_number" id="9aIs`A]0|l^:;vfa5~9}">
            <field name="MOTOR_NUM">250</field>
          </shadow>
        </value>
        <next>
          <block type="motor_set_speed" id="BU/vD2-NpZ.o`$=p,Cdp">
            <field name="instance_name">F{dqcdhfNR!daaA/Amcp-Kfl.c){Uc6NV*s@jGRWn</field>
            <field name="direction">Motor.CW</field>
            <value name="speed">
              <shadow type="motor_number" id="+p.*q+K?lE658fDe)Q5p">
                <field name="MOTOR_NUM">250</field>
              </shadow>
            </value>
          </block>
        </next>
      </block>
    </statement>
  </block>
  <block type="procedures_defnoreturn" id="_04Q%wWk4G6Zz%_nR^ux" x="692" y="-489">
    <field name="NAME">stop</field>
    <statement name="STACK">
      <block type="motor_stop" id="{cbh8aH:jETA5kd5_Tt0">
        <field name="instance_name">F{dqcdhfNR!daaA/Amcp-SD/n[+bi,BfGY~A=zm:W</field>
        <next>
          <block type="motor_stop" id="-`x^3}A8@kf;.!DYuL]M">
            <field name="instance_name">F{dqcdhfNR!daaA/Amcp-Kfl.c){Uc6NV*s@jGRWn</field>
          </block>
        </next>
      </block>
    </statement>
  </block>
  <block type="procedures_defnoreturn" id="NBF*RLWjmEO?nW=kBEK!" x="-575" y="-310">
    <field name="NAME">follow_line</field>
    <statement name="STACK">
      <block type="controls_whileUntil" id="y,v:gNLHS66#1$=9zfik">
        <field name="MODE">WHILE</field>
        <value name="BOOL">
          <block type="logic_operation" id="u8$Gk%}ih3vustEvpB)D">
            <field name="OP">AND</field>
            <value name="A">
              <block type="logic_operation" id="~R1Dv9+HHQk-(OoZituB">
                <field name="OP">OR</field>
                <value name="A">
                  <block type="input_ir_track_sensor_if_value" id=";4X$DH_k0=pQEWwEoY,`">
                    <field name="instance_name">F{dqcdhfNR!daaA/Amcp-U4]r+{fsm~ciQyQHS$xn</field>
                    <field name="compare_operation">==</field>
                    <value name="value">
                      <shadow type="math_number" id="W[C_(y-Q^o%W{^!veHeg">
                        <field name="NUM">0</field>
                      </shadow>
                    </value>
                  </block>
                </value>
                <value name="B">
                  <block type="input_ir_track_sensor_if_value" id="+Z`7z3-:4atn?e?gd0bX">
                    <field name="instance_name">F{dqcdhfNR!daaA/Amcp-|Wyj4^V*L.J!b8SVC(Gd</field>
                    <field name="compare_operation">==</field>
                    <value name="value">
                      <shadow type="math_number" id="r8jzh4L@m[+G0B6uneN+">
                        <field name="NUM">0</field>
                      </shadow>
                    </value>
                  </block>
                </value>
              </block>
            </value>
            <value name="B">
              <block type="logic_compare" id="s.IJn;d{v.LA^AM{r{X4">
                <field name="OP">LT</field>
                <value name="A">
                  <block type="i2c_gesture_sensor_get" id="T=EJ3~r$:/7;w6|.aqqj">
                    <field name="instance_name">F{dqcdhfNR!daaA/Amcp-)nuf/Hy7N3)uO,7+g[Mq</field>
                    <field name="property_name">proximity</field>
                  </block>
                </value>
                <value name="B">
                  <block type="math_number" id="h^}V6cv_i!=9Ua-R8~;-">
                    <field name="NUM">240</field>
                  </block>
                </value>
              </block>
            </value>
          </block>
        </value>
        <statement name="DO">
          <block type="controls_if" id="y?v4Dr6j`nfE~]Q=%h`Q">
            <value name="IF0">
              <block type="input_ir_track_sensor_if_value" id="dYz=(=F-mgr?AM+$!4FJ">
                <field name="instance_name">F{dqcdhfNR!daaA/Amcp-|Wyj4^V*L.J!b8SVC(Gd</field>
                <field name="compare_operation">==</field>
                <value name="value">
                  <shadow type="math_number" id="SPcsszy6fK4,_b;2{wHz">
                    <field name="NUM">1</field>
                  </shadow>
                </value>
              </block>
            </value>
            <statement name="DO0">
              <block type="procedures_callnoreturn" id="-`+(RKq1T]Ol2On)3Trc">
                <mutation name="turn_left"/>
                <next>
                  <block type="util_wait_for" id=",zg!I5!/Zdj_)kbr3s2]">
                    <field name="format">s</field>
                    <value name="value">
                      <shadow type="math_number" id="2J=LrkEtjd}8k8jLv%q4">
                        <field name="NUM">0.05</field>
                      </shadow>
                    </value>
                  </block>
                </next>
              </block>
            </statement>
            <next>
              <block type="controls_if" id="%d%Ty?gW?;A}hmS$~hf,">
                <value name="IF0">
                  <block type="input_ir_track_sensor_if_value" id="Bbv_jhhYbSIqWP-w_e--">
                    <field name="instance_name">F{dqcdhfNR!daaA/Amcp-U4]r+{fsm~ciQyQHS$xn</field>
                    <field name="compare_operation">==</field>
                    <value name="value">
                      <shadow type="math_number" id="v3RK^.*9_5lK=[X`odK7">
                        <field name="NUM">1</field>
                      </shadow>
                    </value>
                  </block>
                </value>
                <statement name="DO0">
                  <block type="procedures_callnoreturn" id="nAuFc|[t]g}+-V7POja{">
                    <mutation name="turn_right"/>
                    <next>
                      <block type="util_wait_for" id="o;2(W|~E5T}5oBy?Hxdc">
                        <field name="format">s</field>
                        <value name="value">
                          <shadow type="math_number" id="$bx)S_bW=s^Ik^Wye0~J">
                            <field name="NUM">0.05</field>
                          </shadow>
                        </value>
                      </block>
                    </next>
                  </block>
                </statement>
                <next>
                  <block type="controls_if" id="_bPHz(64@MR7$f94[XbR">
                    <value name="IF0">
                      <block type="logic_operation" id="V/|j~aY+$?@IsO(caiE)">
                        <field name="OP">AND</field>
                        <value name="A">
                          <block type="input_ir_track_sensor_if_value" id="KiE`89.pZEVT,?r*zW.}">
                            <field name="instance_name">F{dqcdhfNR!daaA/Amcp-U4]r+{fsm~ciQyQHS$xn</field>
                            <field name="compare_operation">==</field>
                            <value name="value">
                              <shadow type="math_number" id="(;LYDanB;~S[D+tI-L4V">
                                <field name="NUM">0</field>
                              </shadow>
                            </value>
                          </block>
                        </value>
                        <value name="B">
                          <block type="input_ir_track_sensor_if_value" id="o|U=M*DZwjN}R,::3{8A">
                            <field name="instance_name">F{dqcdhfNR!daaA/Amcp-|Wyj4^V*L.J!b8SVC(Gd</field>
                            <field name="compare_operation">==</field>
                            <value name="value">
                              <shadow type="math_number" id="xHv-~%/.$tT_4}1Ach(;">
                                <field name="NUM">0</field>
                              </shadow>
                            </value>
                          </block>
                        </value>
                      </block>
                    </value>
                    <statement name="DO0">
                      <block type="procedures_callnoreturn" id="#61N.u*p1hJp[R8:O7e!">
                        <mutation name="forward">
                          <arg name="speed"/>
                        </mutation>
                        <value name="ARG0">
                          <block type="math_number" id="B{}#PZjP2aZp8*kqlYw2">
                            <field name="NUM">250</field>
                          </block>
                        </value>
                      </block>
                    </statement>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </statement>
        <next>
          <block type="controls_if" id="5$(!Hp=secP?:djNTi|k">
            <value name="IF0">
              <block type="logic_compare" id="Xw;:1uE9zW0y%f4/!wEO">
                <field name="OP">GTE</field>
                <value name="A">
                  <block type="i2c_gesture_sensor_get" id="N!/,v(8j?UGr|s8+`_|7">
                    <field name="instance_name">F{dqcdhfNR!daaA/Amcp-)nuf/Hy7N3)uO,7+g[Mq</field>
                    <field name="property_name">proximity</field>
                  </block>
                </value>
                <value name="B">
                  <block type="math_number" id="Tb2WxW~cjH+gQ{QC@^pR">
                    <field name="NUM">240</field>
                  </block>
                </value>
              </block>
            </value>
            <statement name="DO0">
              <block type="procedures_callnoreturn" id="G]Q%FtWlvI,Cm.ohMpWO">
                <mutation name="backward">
                  <arg name="speed"/>
                </mutation>
                <value name="ARG0">
                  <block type="math_number" id="p=N]@jL?Cw%^Ve)P=XLj">
                    <field name="NUM">250</field>
                  </block>
                </value>
                <next>
                  <block type="util_wait_for" id="S+1%ZtG$VgitH6ZxxW1z">
                    <field name="format">s</field>
                    <value name="value">
                      <shadow type="math_number" id="_nVW|)%YK}sJ0[Rf$T5i">
                        <field name="NUM">1</field>
                      </shadow>
                    </value>
                    <next>
                      <block type="controls_if" id="nfsdm}oZZ,Au(u#=(bz`">
                        <mutation elseif="0" else="1"/>
                        <value name="IF0">
                          <block type="logic_compare" id="_i6+4:bN.sP%kpWoF*#}">
                            <field name="OP">EQ</field>
                            <value name="A">
                              <block type="math_number" id="Hyre}K,;XU5/a@VN;6TI">
                                <field name="NUM">1</field>
                              </block>
                            </value>
                            <value name="B">
                              <block type="math_random_int" id="K[=aB|SdF%.cc[z}**9o">
                                <value name="FROM">
                                  <shadow type="math_number" id="{2E5+]y!i{hoJIXRc;{:">
                                    <field name="NUM">1</field>
                                  </shadow>
                                </value>
                                <value name="TO">
                                  <shadow type="math_number" id="w%?MHkXLpUDe2,HR^/#8">
                                    <field name="NUM">2</field>
                                  </shadow>
                                </value>
                              </block>
                            </value>
                          </block>
                        </value>
                        <statement name="DO0">
                          <block type="variables_set" id="ycN9}#tS]KABzt{Towf-">
                            <field name="VAR" id="FI;HT?u`GmEpXC~nKAUD">directions</field>
                            <value name="VALUE">
                              <block type="text" id="?0|K_rwP,P9.=!@v4**{">
                                <field name="TEXT">Right</field>
                              </block>
                            </value>
                            <next>
                              <block type="procedures_callnoreturn" id="xk|79FC0nlu],]15A}].">
                                <mutation name="turn_right"/>
                              </block>
                            </next>
                          </block>
                        </statement>
                        <statement name="ELSE">
                          <block type="variables_set" id="RMu7BJVK2NCO*#!OKPAu">
                            <field name="VAR" id="FI;HT?u`GmEpXC~nKAUD">directions</field>
                            <value name="VALUE">
                              <block type="text" id="040VU#HaG0/]u+#s/DS.">
                                <field name="TEXT">Left</field>
                              </block>
                            </value>
                            <next>
                              <block type="procedures_callnoreturn" id="^=t++pTt(-o?,z#bZNO}">
                                <mutation name="turn_left"/>
                              </block>
                            </next>
                          </block>
                        </statement>
                        <next>
                          <block type="util_wait_for" id="+lsRF32V%cp^H[n{,E2K">
                            <field name="format">s</field>
                            <value name="value">
                              <shadow type="math_number" id="4A6Z#^5mwo1)0!*5W.n:">
                                <field name="NUM">0.5</field>
                              </shadow>
                            </value>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </next>
              </block>
            </statement>
          </block>
        </next>
      </block>
    </statement>
  </block>
  <block type="procedures_defnoreturn" id="w|xL/%wBMuBt]wX4sBA=" x="-32" y="232">
    <mutation>
      <arg name="directions" varid="FI;HT?u`GmEpXC~nKAUD" argid="!P)u+Qdj]-l%JFt/~9vh"/>
    </mutation>
    <field name="NAME">find_line</field>
    <field name="!P)u+Qdj]-l%JFt/~9vh">directions</field>
    <statement name="STACK">
      <block type="controls_whileUntil" id="Ry:vNc[xeN1j6U82+eRD">
        <field name="MODE">WHILE</field>
        <value name="BOOL">
          <block type="logic_operation" id="DAK2:RCX^a;!#Q-j[A5.">
            <field name="OP">AND</field>
            <value name="A">
              <block type="input_ir_track_sensor_if_value" id="tWt[_|~m2Av[b3`s.F$V">
                <field name="instance_name">F{dqcdhfNR!daaA/Amcp-U4]r+{fsm~ciQyQHS$xn</field>
                <field name="compare_operation">==</field>
                <value name="value">
                  <shadow type="math_number" id="}{bJLI#pM]G1Q_*XxkBD">
                    <field name="NUM">1</field>
                  </shadow>
                </value>
              </block>
            </value>
            <value name="B">
              <block type="input_ir_track_sensor_if_value" id="{.+!}f8l]r-(j0b|YcK1">
                <field name="instance_name">F{dqcdhfNR!daaA/Amcp-|Wyj4^V*L.J!b8SVC(Gd</field>
                <field name="compare_operation">==</field>
                <value name="value">
                  <shadow type="math_number" id="FY3%(/o84s-8/I[2SOcd">
                    <field name="NUM">1</field>
                  </shadow>
                </value>
              </block>
            </value>
          </block>
        </value>
        <statement name="DO">
          <block type="controls_if" id="4{=:y~SSeo3zt,%S_:E#">
            <mutation elseif="0" else="1"/>
            <value name="IF0">
              <block type="logic_compare" id="2:.0zkLKrEc)!Z26c_M-">
                <field name="OP">EQ</field>
                <value name="A">
                  <block type="variables_get" id="qD6$~R!J8IB)3_fxp+AG">
                    <field name="VAR" id="FI;HT?u`GmEpXC~nKAUD">directions</field>
                  </block>
                </value>
                <value name="B">
                  <block type="text" id="nc1Q/:FQ%ffULR7BkK.r">
                    <field name="TEXT">Right</field>
                  </block>
                </value>
              </block>
            </value>
            <statement name="DO0">
              <block type="procedures_callnoreturn" id="6JPf,]MNt`ZtqNj~^*iH">
                <mutation name="turn_right"/>
              </block>
            </statement>
            <statement name="ELSE">
              <block type="procedures_callnoreturn" id="([6$W/pFxU*bH[o[EOGs">
                <mutation name="turn_left"/>
              </block>
            </statement>
          </block>
        </statement>
      </block>
    </statement>
  </block>
  <block type="start_block" id="[3Im|}Jr$jX(=e,w_#(:" deletable="false" x="-529" y="527">
    <statement name="statement">
      <block type="i2c_gesture_sensor_enable" id="?+kzys9nxSLXvh_)u0KS">
        <field name="instance_name">F{dqcdhfNR!daaA/Amcp-)nuf/Hy7N3)uO,7+g[Mq</field>
        <field name="state">enable</field>
        <field name="property_name">proximity</field>
        <next>
          <block type="variables_set" id="k(GkIrarCmao^]IyTTUY">
            <field name="VAR" id="FI;HT?u`GmEpXC~nKAUD">directions</field>
            <value name="VALUE">
              <block type="text" id="SDNVq_ze|~t}Ed*Q@Yc7">
                <field name="TEXT">Left</field>
              </block>
            </value>
            <next>
              <block type="loop_endless" id="sR.MFe^q3keiX#b4/3nB">
                <statement name="DO">
                  <block type="procedures_callnoreturn" id="kkO0*hY`X/D^udc;Q0C8">
                    <mutation name="find_line">
                      <arg name="directions"/>
                    </mutation>
                    <value name="ARG0">
                      <block type="variables_get" id="h-pvzLnX#(#iVt4D(*[R">
                        <field name="VAR" id="FI;HT?u`GmEpXC~nKAUD">directions</field>
                      </block>
                    </value>
                    <next>
                      <block type="procedures_callnoreturn" id="n?N55(?!HRO%!VZz7QDj">
                        <mutation name="follow_line"/>
                      </block>
                    </next>
                  </block>
                </statement>
              </block>
            </next>
          </block>
        </next>
      </block>
    </statement>
  </block>
</xml>