team3testing.py
← Back to Programs · Download team3testing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# pybricks blocks file:{"blocks":{"languageVersion":0,"blocks":[{"type":"blockGlobalSetup","id":"bjK,wS1MYO7aiYkFSwd{","x":3,"y":25,"deletable":false,"next":{"block":{"type":"variables_set_prime_hub","id":"/kPZ63`R?7vE8jZjfuui","extraState":{"optionLevel":0},"fields":{"VAR":{"id":"C8UKJH3Nw(9a8PVNuM1f"}},"next":{"block":{"type":"variables_set_motor","id":"`J%Ck*}oK*[W?niBwLN.","fields":{"VAR":{"id":"4]G-GBa4Ea4w;!syr_Zd"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":"9mVG2r(K?11~LuvQ`WPl","fields":{"NAME":"D"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"_%%(H}$[euOFg!.(Q:bT","fields":{"SELECTION":"Direction.COUNTERCLOCKWISE"}}}},"next":{"block":{"type":"variables_set_motor","id":"8zWA89Uph2iwj.jy]!iG","fields":{"VAR":{"id":"lb7=i,iiz`q}x%0H4p;7"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":"X!d_CxS%dkL`x_Hcz`FV","fields":{"NAME":"F"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"zES1c-$INw2h{(iGKyDw","fields":{"SELECTION":"Direction.CLOCKWISE"}}}},"next":{"block":{"type":"variables_set_drive_base","id":"]o#Am*;]QNMIoH.uS8Dx","fields":{"VAR":{"id":"j6XvHS(``y0t9[zIYNUl"}},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"t;I,qMdhAqXR|@jO(7Z@","fields":{"VAR":{"id":"4]G-GBa4Ea4w;!syr_Zd","name":"left wheel","type":"Motor"}}}},"VAR2":{"shadow":{"type":"variables_get_motor_device","id":"*0s1_`mjLF8TmNHhYONF","fields":{"VAR":{"id":"lb7=i,iiz`q}x%0H4p;7","name":"right wheel","type":"Motor"}}}},"VALUE0":{"shadow":{"type":"unit_distance","id":"OfqJOv2$U1b/G=6czAwW","fields":{"VALUE0":70}}},"VALUE1":{"shadow":{"type":"unit_distance","id":"UU0wgs.nQiabYjP(@Z`#","fields":{"VALUE0":125}}}}}}}}}}}}},{"type":"blockGlobalStart","id":"3tJe|AWl0baN(wH9a$@.","x":150,"y":300,"deletable":false,"next":{"block":{"type":"blockPrint","id":"j,,T}?rBkaW$1v?olp4p","extraState":{"optionLevel":0},"inputs":{"TEXT0":{"shadow":{"type":"text","id":"!x5.0YiWya^`(y)yO5B8","fields":{"TEXT":"Hello, Pybricks!"}}}},"next":{"block":{"type":"blockDriveBaseDrive2","id":"4#]Ua/,QF[/R30xnK10c","extraState":{"optionLevel":2},"fields":{"METHOD":"DRIVEBASE_DRIVE_STRAIGHT"},"inputs":{"VAR":{"shadow":{"type":"variables_get_drive_base_device","id":"4=V(QdHGY[}?+6%~]A1m","fields":{"VAR":{"id":"j6XvHS(``y0t9[zIYNUl","name":"drive base","type":"DriveBase"}}}},"ARG0":{"shadow":{"type":"unit_distance","id":"n=M;-J=`7+OAA8tjuZ!W","fields":{"VALUE0":500}}},"ARG1":{"shadow":{"type":"parameters_stop_4","id":"9%2[ctg;xS^r8@^7;DYD","fields":{"VALUE":"Stop.NONE"}}}},"next":{"block":{"type":"blockDriveBaseDrive2","id":"LsLuSB)23iMG6N95~{B|","extraState":{"optionLevel":3},"fields":{"METHOD":"DRIVEBASE_DRIVE_TURN"},"inputs":{"VAR":{"shadow":{"type":"variables_get_drive_base_device","id":"Zjf#Nd`VS)T~V|$K,_*r","fields":{"VAR":{"id":"j6XvHS(``y0t9[zIYNUl","name":"drive base","type":"DriveBase"}}}},"ARG0":{"shadow":{"type":"unit_angle","id":";z2b-+.yHp}dFQ;~|?xN","fields":{"VALUE0":-90}}},"ARG1":{"shadow":{"type":"parameters_stop_4","id":"((VyKlfcn@%-O@v$39=P","fields":{"VALUE":"Stop.BRAKE"}}}},"next":{"block":{"type":"blockDriveBaseDrive2","id":"oEX${6^.{.a;FeDMm2E{","extraState":{"optionLevel":2},"fields":{"METHOD":"DRIVEBASE_DRIVE_STRAIGHT"},"inputs":{"VAR":{"shadow":{"type":"variables_get_drive_base_device","id":"y]JS*2r[0+0$ZX*vPGt(","fields":{"VAR":{"id":"j6XvHS(``y0t9[zIYNUl","name":"drive base","type":"DriveBase"}}}},"ARG0":{"shadow":{"type":"unit_distance","id":"A:3,czPgH:f=f!Ee%|H5","fields":{"VALUE0":250}}},"ARG1":{"shadow":{"type":"parameters_stop_4","id":"R-u`^KA;w*d4$h`O^5F+","fields":{"VALUE":"Stop.HOLD"}}}},"next":{"block":{"type":"blockDriveBaseDrive2","id":"-Bl=]aY*;X3KPNAG;8uh","extraState":{"optionLevel":2},"fields":{"METHOD":"DRIVEBASE_DRIVE_STRAIGHT"},"inputs":{"VAR":{"shadow":{"type":"variables_get_drive_base_device","id":"R1*A(0Z].!yMeXwP:|5=","fields":{"VAR":{"id":"j6XvHS(``y0t9[zIYNUl","name":"drive base","type":"DriveBase"}}}},"ARG0":{"shadow":{"type":"unit_distance","id":"j,roSaevbE:Aa=Jir9C8","fields":{"VALUE0":-250}}},"ARG1":{"shadow":{"type":"parameters_stop_4","id":"Lyczl%IdRBS0g;B3PtaJ","fields":{"VALUE":"Stop.HOLD"}}}},"next":{"block":{"type":"blockDriveBaseDrive2","id":"cWz9VwVV|Cw0,B,_F:B|","extraState":{"optionLevel":3},"fields":{"METHOD":"DRIVEBASE_DRIVE_TURN"},"inputs":{"VAR":{"shadow":{"type":"variables_get_drive_base_device","id":"v;IYL#0({`X{#YzE7.2b","fields":{"VAR":{"id":"j6XvHS(``y0t9[zIYNUl","name":"drive base","type":"DriveBase"}}}},"ARG0":{"shadow":{"type":"unit_angle","id":"#lqq5AzlVN%f}w}$.gO=","fields":{"VALUE0":90}}},"ARG1":{"shadow":{"type":"parameters_stop_4","id":"Co@1y4R4s2oAchSU4TJM","fields":{"VALUE":"Stop.BRAKE"}}}},"next":{"block":{"type":"blockDriveBaseDrive2","id":"#nxnn$O7{#5n0a-u1-9:","extraState":{"optionLevel":2},"fields":{"METHOD":"DRIVEBASE_DRIVE_STRAIGHT"},"inputs":{"VAR":{"shadow":{"type":"variables_get_drive_base_device","id":"@n.OEa/Yw#x1;[=m,gQH","fields":{"VAR":{"id":"j6XvHS(``y0t9[zIYNUl","name":"drive base","type":"DriveBase"}}}},"ARG0":{"shadow":{"type":"unit_distance","id":"rT?l=S+np7ITv_(??y=N","fields":{"VALUE0":-500}}},"ARG1":{"shadow":{"type":"parameters_stop_4","id":"M?.Y9/X714G*2%4nu%o;","fields":{"VALUE":"Stop.HOLD"}}}}}}}}}}}}}}}}}}}]},"variables":[{"name":"red","id":"{w8)^^4vs%nQOMQVD2-2","type":"ColorDef"},{"name":"orange","id":"e?rUJ5[h*i:Vf{*|FW~.","type":"ColorDef"},{"name":"yellow","id":"HZ(K7=2P%ty~p8!T6UuV","type":"ColorDef"},{"name":"green","id":"k`Lmot,7*@lHuJ[t^:/S","type":"ColorDef"},{"name":"cyan","id":"Up)l[}L]SLW_J.V4)BU(","type":"ColorDef"},{"name":"blue","id":"$ZI/$.`^WU#8X3u4h?U,","type":"ColorDef"},{"name":"violet","id":",pW?RYY33%MS2s%hz*xV","type":"ColorDef"},{"name":"magenta","id":"ta|J.Y*L.K4Ym!#|Jr1F","type":"ColorDef"},{"name":"white","id":"Bbs%Q0C?#?UvCH9++e00","type":"ColorDef"},{"name":"none","id":"[?dAFvJ.f={vDbY-JPXH","type":"ColorDef"},{"name":"prime hub","id":"C8UKJH3Nw(9a8PVNuM1f","type":"PrimeHub"},{"name":"drive base","id":"j6XvHS(``y0t9[zIYNUl","type":"DriveBase"},{"name":"left wheel","id":"4]G-GBa4Ea4w;!syr_Zd","type":"Motor"},{"name":"right wheel","id":"lb7=i,iiz`q}x%0H4p;7","type":"Motor"}],"info":{"type":"pybricks","version":"1.3.2"}}
from pybricks.hubs import PrimeHub
from pybricks.parameters import Direction, Port, Stop
from pybricks.pupdevices import Motor
from pybricks.robotics import DriveBase
# Set up all devices.
prime_hub = PrimeHub()
left_wheel = Motor(Port.D, Direction.COUNTERCLOCKWISE)
right_wheel = Motor(Port.F, Direction.CLOCKWISE)
drive_base = DriveBase(left_wheel, right_wheel, 70, 125)
# The main program starts here.
print('Hello, Pybricks!')
drive_base.straight(500, then=Stop.NONE)
drive_base.turn(-90, then=Stop.BRAKE)
drive_base.straight(250)
drive_base.straight(-250)
drive_base.turn(90, then=Stop.BRAKE)
drive_base.straight(-500)