-
Notifications
You must be signed in to change notification settings - Fork 0
/
technic42100top.py
49 lines (45 loc) · 17.6 KB
/
technic42100top.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# pybricks blocks file:{"blocks":{"languageVersion":0,"blocks":[{"type":"blockGlobalSetup","id":"bjK,wS1MYO7aiYkFSwd{","x":0,"y":0,"deletable":false,"next":{"block":{"type":"variables_set_technic_hub","id":"Bs=Ro`lb:O-F.aLpChZ4","extraState":{"optionLevel":3},"fields":{"VAR":{"id":"R73J-,nNu.%J/{yrcP%6"},"FIELDBROADCAST":1,"FIELDOBSERVE0":0},"inputs":{"AXIS_TOP":{"shadow":{"type":"blockParametersAxis","id":"i*VF|n5;x)S?,XOy5R%(","fields":{"VALUE":"z"}}},"AXIS_FRONT":{"shadow":{"type":"blockParametersAxis","id":"CxREpMjE{C9bsX?|qC5X","fields":{"VALUE":"x"}}}},"next":{"block":{"type":"variables_set_motor","id":"i[oUu_4KeH}Yc;#VPu/,","fields":{"VAR":{"id":"`sPaH4dlS(^!Z]jb`-k9"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":"iQjED-1RnyNC_pL(Sw:(","fields":{"NAME":"A"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"24n1X+ee_cu[RoOAS`#8","fields":{"SELECTION":"Direction.COUNTERCLOCKWISE"}}}},"next":{"block":{"type":"variables_set_motor","id":"@0C!sv(:/?]ooHZ__=:K","fields":{"VAR":{"id":"=$/(.BE|4B;Wbn).@7WF"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":"iwcnb??}N7/=*b_/w*=k","fields":{"NAME":"C"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"fI^BzY}Q~=?xcmV7vvhE","fields":{"SELECTION":"Direction.CLOCKWISE"}}}},"next":{"block":{"type":"variables_set_motor","id":"_Yme3z:NRi!@dSU+Mt~,","fields":{"VAR":{"id":"wy9jL4RTz9b6N;6)_8~m"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":",aI#Gz4+!!7b:4gJ1|1M","fields":{"NAME":"B"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"8,b@MZbsH2D]in!u5[sV","fields":{"SELECTION":"Direction.COUNTERCLOCKWISE"}}}},"next":{"block":{"type":"variables_set_motor","id":"6W#fF51`-]t~!,U`v4lk","fields":{"VAR":{"id":"B7m1h5d)N,L*Aj)(7Aq9"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":".jIxcj2%8Euv:=u[7X*q","fields":{"NAME":"D"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"UggTe9+sY/;|A/~mi1ib","fields":{"SELECTION":"Direction.CLOCKWISE"}}}},"next":{"block":{"type":"variables_setup_any","id":"cRbJc`c{:#S4:rAw%T!r","fields":{"VAR":{"id":"?S_jd7#u_ge_DGXE14W5"}},"inputs":{"VALUE0":{"shadow":{"type":"blockMathNumber","id":"mCN5(Y]`Y]3pV?bEaxwR","fields":{"NUM":0}}}},"next":{"block":{"type":"variables_setup_any","id":"P^P!JX~?w~D%)nuLnNAt","fields":{"VAR":{"id":"Sr$/Z}BA:{=Pj}u0O$zu"}},"inputs":{"VALUE0":{"shadow":{"type":"blockMathNumber","id":"WP^$IC:!Z-V}F0Y*D,|z","fields":{"NUM":0}}}},"next":{"block":{"type":"variables_setup_any","id":"@jnQy+W[QIpB4YV)I@#b","fields":{"VAR":{"id":"lDZPw0t/9:I5P8[K,Vzo"}},"inputs":{"VALUE0":{"shadow":{"type":"blockMathNumber","id":"8wS%-k]o4rLp=$`8,D7;","fields":{"NUM":0}}}},"next":{"block":{"type":"variables_setup_any","id":"Uz^Z^3Auon870abe-OJT","fields":{"VAR":{"id":":(s`nUP~(xP4K}ms-xt7"}},"inputs":{"VALUE0":{"shadow":{"type":"blockMathNumber","id":"Q#`n4a41_?kiGQAmC_]:","fields":{"NUM":0}}}},"next":{"block":{"type":"variables_setup_any","id":"2,rQ,G?$G%s:*hg}9MpQ","fields":{"VAR":{"id":"c5Q-m`T?=c86SaOx#O8N"}},"inputs":{"VALUE0":{"shadow":{"type":"blockMathNumber","id":"J?jL#LvZe|vY$r6;b(T#","fields":{"NUM":0}}}}}}}}}}}}}}}}}}}}}}}}},{"type":"blockGlobalStart","id":"3tJe|AWl0baN(wH9a$@.","x":0,"y":569,"deletable":false,"next":{"block":{"type":"blockMotorConfigure","id":"TUQBX/J|OnmgPhV35;XO","extraState":{"optionLevel":1},"fields":{"METHOD":"MOTOR_ACCELERATION"},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"l;Z$vZU5rNJ=ZpewVUF}","fields":{"VAR":{"id":"`sPaH4dlS(^!Z]jb`-k9","name":"m1","type":"Motor"}}}},"ARG0":{"shadow":{"type":"unit_angularAcceleration","id":")mqq^;B/[wh|^[@Hqu#^","fields":{"VALUE0":2500}}}},"next":{"block":{"type":"blockMotorConfigure","id":"!(0e7-(rVkiNbJ?@2?ej","extraState":{"optionLevel":1},"fields":{"METHOD":"MOTOR_ACCELERATION"},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"AQq+u+DHgZbMTxC+f.(?","fields":{"VAR":{"id":"=$/(.BE|4B;Wbn).@7WF","name":"m2","type":"Motor"}}}},"ARG0":{"shadow":{"type":"unit_angularAcceleration","id":"B~,xFsaZ,Bzog7%2gcu=","fields":{"VALUE0":2500}}}},"next":{"block":{"type":"blockMotorConfigure","id":";!IJ:(mU68iL2~T,|1fE","extraState":{"optionLevel":1},"fields":{"METHOD":"MOTOR_ACCELERATION"},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"@SpVh7Sn)]a;(-4vI?Ze","fields":{"VAR":{"id":"wy9jL4RTz9b6N;6)_8~m","name":"m3","type":"Motor"}}}},"ARG0":{"shadow":{"type":"unit_angularAcceleration","id":"p%gxt!+Q(I;mz:_fo_U!","fields":{"VALUE0":2500}}}},"next":{"block":{"type":"blockMotorConfigure","id":"9:_{7t`fr.^@aI%VL7z%","extraState":{"optionLevel":1},"fields":{"METHOD":"MOTOR_ACCELERATION"},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"RZq7UjPJ{uM)XlBdV$t7","fields":{"VAR":{"id":"B7m1h5d)N,L*Aj)(7Aq9","name":"bucket","type":"Motor"}}}},"ARG0":{"shadow":{"type":"unit_angularAcceleration","id":"f6tKjHVI;SGzT~_8h)?z","fields":{"VALUE0":2500}}}},"next":{"block":{"type":"blockLightOnColor","id":"1ZLo9)$i;-)sFSX[sav`","extraState":{"optionLevel":1},"fields":{"METHOD":"LIGHT_ON"},"inputs":{"VAR":{"shadow":{"type":"variables_get_color_light_device","id":"gC)NGBC#`KZH^WSxe[OE","fields":{"VAR":{"id":"R73J-,nNu.%J/{yrcP%6","name":"top","type":"TechnicHub"}}}},"COLOR":{"shadow":{"type":"variables_get_color","id":"D(33F8T#HeI=$;rP;=;q","fields":{"COLOUR":"#00ff00","VAR":{"id":";,TwX_00$o;[-by%HuSZ","name":"green","type":"ColorDef"}}}}},"next":{"block":{"type":"blockFlowWhile","id":"INz;NYIbAx}-)4D:ZW[B","fields":{"MODE":"WHILE"},"inputs":{"BOOL":{"shadow":{"type":"blockLogicTrue","id":"8~K2@dX|hvN8P?H~[3xm"}},"DO":{"block":{"type":"blockListUnpack","id":"3|~lzfIvY57Qukvvw;x@","extraState":{"optionLevel":4},"inputs":{"LIST":{"shadow":{"type":"blockListEmpty","id":"BY?6!ogw%%FdE%hiKmU4"},"block":{"type":"blockBleObserve","id":"5%b/g:b`A(RkyBfe04%X","fields":{"CHANNEL":"0"},"inputs":{"VAR":{"shadow":{"type":"variables_get_ble_hub","id":"mYs?C:6)Txv1x,mj,ogJ","fields":{"VAR":{"id":"R73J-,nNu.%J/{yrcP%6","name":"top","type":"TechnicHub"}}}}}}},"VAR":{"shadow":{"type":"variables_get_any","id":"6n`-12;pqi-Zz~gy3f;6","fields":{"VAR":{"id":"Sf(Y1`vUXo7}$~zFDVrS","name":"i","type":"Any"}}},"block":{"type":"blockVariableGetValue","id":"O^j:+Q.HEfl:tWVj:Ww7","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":".%SiD.#yTHujN62[=]Zv","fields":{"VAR":{"id":"?S_jd7#u_ge_DGXE14W5","name":"left joystic vertical","type":"Any"}}}}}}},"VAR0":{"shadow":{"type":"variables_get_any","id":"XLc_T8|/q!e7U^`u5}JS","fields":{"VAR":{"id":"Sr$/Z}BA:{=Pj}u0O$zu","name":"right joystic horizontal","type":"Any"}}}},"VAR1":{"shadow":{"type":"variables_get_any","id":"68-$mB%*44=ApT=X4rLN","fields":{"VAR":{"id":"lDZPw0t/9:I5P8[K,Vzo","name":"right joystic vertical","type":"Any"}}}},"VAR2":{"shadow":{"type":"variables_get_any","id":"?y16s,+`s%*Yc@fZO}K7","fields":{"VAR":{"id":":(s`nUP~(xP4K}ms-xt7","name":"joystick A pressed","type":"Any"}}}},"VAR3":{"shadow":{"type":"variables_get_any","id":"b]6Ib-QW[Wv9yf=rfqL.","fields":{"VAR":{"id":"c5Q-m`T?=c86SaOx#O8N","name":"joystick B pressed","type":"Any"}}}}},"next":{"block":{"type":"blockIfElse","id":"m,h[c)x(Y~bH.y`4=F_X","extraState":{"optionLevel":0},"inputs":{"IF0":{"shadow":{"type":"blockLogicTrue","id":"cV3^!?^bJ)PN|suX0No)"},"block":{"type":"blockButtonIsPressed","id":"K-Py:vR7r;(C5;7IOrqU","inputs":{"VAR":{"shadow":{"type":"variables_get_keypad","id":"#Flxgl|.UjR`wlZUIqt#","fields":{"VAR":{"id":"R73J-,nNu.%J/{yrcP%6","name":"top","type":"TechnicHub"}}}},"VALUE0":{"shadow":{"type":"blockParametersButton","id":"b^wSl2GK0z}`)gVJ^.V^","fields":{"VALUE":"CENTER"}}}}}},"DO0":{"block":{"type":"blockHubShutdown","id":"CM.*Bt23^[email protected]=l","inputs":{"VAR":{"shadow":{"type":"variables_get_button_hub","id":"*3kTKpg+k2_+_wqoJ6j)","fields":{"VAR":{"id":"R73J-,nNu.%J/{yrcP%6","name":"top","type":"TechnicHub"}}}}}}}},"next":{"block":{"type":"blockIfElse","id":"Cj8RG[L,|B1~uMAoUckE","extraState":{"optionLevel":1},"inputs":{"IF0":{"shadow":{"type":"blockLogicTrue","id":"5=*^l?0y^Y%ySbfzDty-"},"block":{"type":"blockVariableGetValue","id":"`g9MnS;0U`hRM=;Fmx,w","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":"*cQxD+k_u;{JjlIR[Q#X","fields":{"VAR":{"id":"?S_jd7#u_ge_DGXE14W5","name":"left joystic vertical","type":"Any"}}}}}}},"DO0":{"block":{"type":"blockMotorRun","id":"9l|eP@BXO0bm3jUk{$[{","extraState":{"optionLevel":0},"fields":{"METHOD":"MOTOR_RUN_FOREVER"},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"W~50%Mq=$E{Rmyv=_]Al","fields":{"VAR":{"id":"`sPaH4dlS(^!Z]jb`-k9","name":"m1","type":"Motor"}}}},"VALUE0":{"shadow":{"type":"unit_angularVelocity","id":"jz~y%}o2@__h9xRV+.mQ","fields":{"VALUE0":500}},"block":{"type":"blockMathArithmetic","id":"(WRI4O+Az(rF@+4L)1)y","fields":{"OP":"MULTIPLY"},"inputs":{"A":{"shadow":{"type":"blockMathNumber","id":"_Gni#@EOqG(mQkoHr8xZ","fields":{"NUM":25}}},"B":{"shadow":{"type":"blockMathNumber","id":"l,#g84:Z;eVS*u;o}5tY","fields":{"NUM":1}},"block":{"type":"blockVariableGetValue","id":"Ghl;2JL1onczH/o7~#j#","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":"4(Tp_{mv@s+20[vB[nh-","fields":{"VAR":{"id":"?S_jd7#u_ge_DGXE14W5","name":"left joystic vertical","type":"Any"}}}}}}}}}}}}},"ELSE":{"block":{"type":"blockMotorStop","id":"jag4,Q$yD@iwGi6CL03N","inputs":{"VAR":{"shadow":{"type":"variables_get_simple_motor_device","id":"6hDz%,2+9s,=EUA}WvdG","fields":{"VAR":{"id":"`sPaH4dlS(^!Z]jb`-k9","name":"m1","type":"Motor"}}}},"VALUE0":{"shadow":{"type":"parameters_stop_3","id":"9R/?0-ax]BEgL8Tdy`r.","fields":{"VALUE":"Stop.BRAKE"}}}}}}},"next":{"block":{"type":"blockIfElse","id":"U89hlPbn?ch/SiF(m`b#","extraState":{"optionLevel":1},"inputs":{"IF0":{"shadow":{"type":"blockLogicTrue","id":"5=*^l?0y^Y%ySbfzDty-"},"block":{"type":"blockVariableGetValue","id":"#0B}56/qj#nn+cDMIHl]","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":",E1.~gL6pjI:~%iObPq2","fields":{"VAR":{"id":"Sr$/Z}BA:{=Pj}u0O$zu","name":"right joystic horizontal","type":"Any"}}}}}}},"DO0":{"block":{"type":"blockMotorRun","id":"_m3v)PrQcPRZ{cE#=jn/","extraState":{"optionLevel":0},"fields":{"METHOD":"MOTOR_RUN_FOREVER"},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"CO^weX@%maX@Ru*qe:x{","fields":{"VAR":{"id":"=$/(.BE|4B;Wbn).@7WF","name":"m2","type":"Motor"}}}},"VALUE0":{"shadow":{"type":"unit_angularVelocity","id":"jz~y%}o2@__h9xRV+.mQ","fields":{"VALUE0":500}},"block":{"type":"blockMathArithmetic","id":"(:{]`6h:QnXT$%Y^7!K:","fields":{"OP":"MULTIPLY"},"inputs":{"A":{"shadow":{"type":"blockMathNumber","id":"1`9iB16z!QMQdvDz$:hP","fields":{"NUM":25}}},"B":{"shadow":{"type":"blockMathNumber","id":"l,#g84:Z;eVS*u;o}5tY","fields":{"NUM":1}},"block":{"type":"blockVariableGetValue","id":"=oz}#Rb43d|@YM#*ZNnO","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":"XVgYopT8xjBh_ITmbD7E","fields":{"VAR":{"id":"Sr$/Z}BA:{=Pj}u0O$zu","name":"right joystic horizontal","type":"Any"}}}}}}}}}}}}},"ELSE":{"block":{"type":"blockMotorStop","id":"@_4NO|f/-23X:za/t@o4","inputs":{"VAR":{"shadow":{"type":"variables_get_simple_motor_device","id":"(`F}gPeRdmgwE%9xm*61","fields":{"VAR":{"id":"=$/(.BE|4B;Wbn).@7WF","name":"m2","type":"Motor"}}}},"VALUE0":{"shadow":{"type":"parameters_stop_3","id":"umK)+l}igP%P]{XdRncv","fields":{"VALUE":"Stop.BRAKE"}}}}}}},"next":{"block":{"type":"blockIfElse","id":"9u^0U~DgA!~k!O@L){fu","extraState":{"optionLevel":1},"inputs":{"IF0":{"shadow":{"type":"blockLogicTrue","id":"5=*^l?0y^Y%ySbfzDty-"},"block":{"type":"blockVariableGetValue","id":"`27c9j%5KPw=vHDtO*k7","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":"(s-%{H1ZG}OfA6L..D[?","fields":{"VAR":{"id":"lDZPw0t/9:I5P8[K,Vzo","name":"right joystic vertical","type":"Any"}}}}}}},"DO0":{"block":{"type":"blockMotorRun","id":"1FAO!j%PUY?L01TSgFV,","extraState":{"optionLevel":0},"fields":{"METHOD":"MOTOR_RUN_FOREVER"},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"GcwyX$v1LCI/po]tnIVT","fields":{"VAR":{"id":"wy9jL4RTz9b6N;6)_8~m","name":"m3","type":"Motor"}}}},"VALUE0":{"shadow":{"type":"unit_angularVelocity","id":"jz~y%}o2@__h9xRV+.mQ","fields":{"VALUE0":500}},"block":{"type":"blockMathArithmetic","id":"60FS[Sr}%7]|8dg?GnOm","fields":{"OP":"MULTIPLY"},"inputs":{"A":{"shadow":{"type":"blockMathNumber","id":")W~^hOb}$X/^4f%eJZdZ","fields":{"NUM":25}}},"B":{"shadow":{"type":"blockMathNumber","id":"l,#g84:Z;eVS*u;o}5tY","fields":{"NUM":1}},"block":{"type":"blockVariableGetValue","id":"as(JALk*3pvf%Z1D`|kl","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":"e*(dDg*_eI,w^I[^oyjp","fields":{"VAR":{"id":"lDZPw0t/9:I5P8[K,Vzo","name":"right joystic vertical","type":"Any"}}}}}}}}}}}}},"ELSE":{"block":{"type":"blockMotorStop","id":"/DI7G^BO/Z]6HX?R:MzQ","inputs":{"VAR":{"shadow":{"type":"variables_get_simple_motor_device","id":"98N[3y)@$$XK[kJf5^$i","fields":{"VAR":{"id":"wy9jL4RTz9b6N;6)_8~m","name":"m3","type":"Motor"}}}},"VALUE0":{"shadow":{"type":"parameters_stop_3","id":"A=^T(p(QGHi1w6$bp+#@","fields":{"VALUE":"Stop.BRAKE"}}}}}}},"next":{"block":{"type":"blockIfElse","id":"sx#N)z1lvr*,T?|l@tEk","extraState":{"optionLevel":1},"inputs":{"IF0":{"shadow":{"type":"blockLogicTrue","id":"5=*^l?0y^Y%ySbfzDty-"},"block":{"type":"blockVariableGetValue","id":"O-3!E)k2jWdC,3[[d[Fx","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":"c*LY^Ea[Omz*{}~QPvIw","fields":{"VAR":{"id":":(s`nUP~(xP4K}ms-xt7","name":"joystick A pressed","type":"Any"}}}}}}},"DO0":{"block":{"type":"blockMotorRun","id":"NuU@*/z9{vfFdI$ep4%t","extraState":{"optionLevel":0},"fields":{"METHOD":"MOTOR_RUN_FOREVER"},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"0]#vF*{F}0A1-H=Lmc?M","fields":{"VAR":{"id":"B7m1h5d)N,L*Aj)(7Aq9","name":"bucket","type":"Motor"}}}},"VALUE0":{"shadow":{"type":"unit_angularVelocity","id":"jz~y%}o2@__h9xRV+.mQ","fields":{"VALUE0":1000}}}}}},"ELSE":{"block":{"type":"blockIfElse","id":"@8Ga?kZ.i=?s]i@!Q}d(","extraState":{"optionLevel":1},"inputs":{"IF0":{"shadow":{"type":"blockLogicTrue","id":"5=*^l?0y^Y%ySbfzDty-"},"block":{"type":"blockVariableGetValue","id":"B(BK2dzuFDvJZz^]D0Gq","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":"L84oqbl0=Nzw,Qo^C5C[","fields":{"VAR":{"id":"c5Q-m`T?=c86SaOx#O8N","name":"joystick B pressed","type":"Any"}}}}}}},"DO0":{"block":{"type":"blockMotorRun","id":"f(aYs]Bv-15}2=Qp!DFS","extraState":{"optionLevel":0},"fields":{"METHOD":"MOTOR_RUN_FOREVER"},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"iQ2S]Vbf:_*gF%0xnjk^","fields":{"VAR":{"id":"B7m1h5d)N,L*Aj)(7Aq9","name":"bucket","type":"Motor"}}}},"VALUE0":{"shadow":{"type":"unit_angularVelocity","id":"%IXfC*AC0aWY#km~LBvD","fields":{"VALUE0":-1000}}}}}},"ELSE":{"block":{"type":"blockMotorStop","id":"2:~IXkn=whd8$|m!DG}q","inputs":{"VAR":{"shadow":{"type":"variables_get_simple_motor_device","id":"Ia.m3n(lC4_%,Wd1a//v","fields":{"VAR":{"id":"B7m1h5d)N,L*Aj)(7Aq9","name":"bucket","type":"Motor"}}}},"VALUE0":{"shadow":{"type":"parameters_stop_3","id":"5zT`POc/3gI]7sjC54/j","fields":{"VALUE":"Stop.BRAKE"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]},"variables":[{"name":"red","id":"F`hZomQiQeM/SE_n2%k#","type":"ColorDef"},{"name":"orange","id":"jI3{qhk%5reA;fvsHg[R","type":"ColorDef"},{"name":"yellow","id":"lx9;5^KGc:oDl2v5wdi=","type":"ColorDef"},{"name":"green","id":";,TwX_00$o;[-by%HuSZ","type":"ColorDef"},{"name":"cyan","id":"/s^WNx;QeN5M9%6II:zK","type":"ColorDef"},{"name":"blue","id":",xm}M2H76+f@85l5uG|B","type":"ColorDef"},{"name":"violet","id":"cx$CI36Bo145ZQ1NYJ5[","type":"ColorDef"},{"name":"magenta","id":"44T*vY1Hwa:uN1DJJBmL","type":"ColorDef"},{"name":"white","id":"h,J+:-Z=#j)w=P+k)Ca@","type":"ColorDef"},{"name":"none","id":"Wkvq0OVz08)sA8%|4763","type":"ColorDef"},{"name":"top","id":"R73J-,nNu.%J/{yrcP%6","type":"TechnicHub"},{"name":"m1","id":"`sPaH4dlS(^!Z]jb`-k9","type":"Motor"},{"name":"m2","id":"=$/(.BE|4B;Wbn).@7WF","type":"Motor"},{"name":"m3","id":"wy9jL4RTz9b6N;6)_8~m","type":"Motor"},{"name":"bucket","id":"B7m1h5d)N,L*Aj)(7Aq9","type":"Motor"},{"name":"left joystic vertical","id":"?S_jd7#u_ge_DGXE14W5","type":"Any"},{"name":"right joystic horizontal","id":"Sr$/Z}BA:{=Pj}u0O$zu","type":"Any"},{"name":"right joystic vertical","id":"lDZPw0t/9:I5P8[K,Vzo","type":"Any"},{"name":"joystick A pressed","id":":(s`nUP~(xP4K}ms-xt7","type":"Any"},{"name":"joystick B pressed","id":"c5Q-m`T?=c86SaOx#O8N","type":"Any"}],"info":{"type":"pybricks","version":"1.2.3"}}
from pybricks.hubs import TechnicHub
from pybricks.parameters import Axis, Button, Color, Direction, Port, Stop
from pybricks.pupdevices import Motor
# Set up all devices.
top = TechnicHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=1, observe_channels=[0])
m1 = Motor(Port.A, Direction.COUNTERCLOCKWISE)
m2 = Motor(Port.C, Direction.CLOCKWISE)
m3 = Motor(Port.B, Direction.COUNTERCLOCKWISE)
bucket = Motor(Port.D, Direction.CLOCKWISE)
# Initialize variables.
left_joystic_vertical = 0
right_joystic_horizontal = 0
right_joystic_vertical = 0
joystick_A_pressed = 0
joystick_B_pressed = 0
# The main program starts here.
m1.control.limits(acceleration=2500)
m2.control.limits(acceleration=2500)
m3.control.limits(acceleration=2500)
bucket.control.limits(acceleration=2500)
top.light.on(Color.GREEN)
while True:
left_joystic_vertical, right_joystic_horizontal, right_joystic_vertical, joystick_A_pressed, joystick_B_pressed = top.ble.observe(0) or [0] * 5
if Button.CENTER in top.buttons.pressed():
top.system.shutdown()
if left_joystic_vertical:
m1.run(25 * left_joystic_vertical)
else:
m1.brake()
if right_joystic_horizontal:
m2.run(25 * right_joystic_horizontal)
else:
m2.brake()
if right_joystic_vertical:
m3.run(25 * right_joystic_vertical)
else:
m3.brake()
if joystick_A_pressed:
bucket.run(1000)
else:
if joystick_B_pressed:
bucket.run(-1000)
else:
bucket.brake()