Files
Lego_Pybricks/42100/lego42100_bot_blocks.py
2024-05-02 07:19:30 +02:00

23 lines
5.6 KiB
Python

# pybricks blocks file:{"blocks":{"languageVersion":0,"blocks":[{"type":"blockGlobalSetup","id":"bjK,wS1MYO7aiYkFSwd{","x":150,"y":100,"deletable":false,"next":{"block":{"type":"variables_set_technic_hub","id":"CDp2C5~8v-U[5-,}t0x`","extraState":{"optionLevel":3},"fields":{"VAR":{"id":".qW5|.{lJTGrt0ogrew^"},"FIELDBROADCAST":0,"FIELDOBSERVE0":1},"inputs":{"AXIS_TOP":{"shadow":{"type":"blockParametersAxis","id":"%3.s1+V/VE66hRqhGgX`","fields":{"VALUE":"z"}}},"AXIS_FRONT":{"shadow":{"type":"blockParametersAxis","id":"Q7nA5!1=|XRI44Xtdd,1","fields":{"VALUE":"x"}}}},"next":{"block":{"type":"variables_set_motor","id":"ANjT,T}UOCFkaPuj!E^|","fields":{"VAR":{"id":"n74#}[-5,:EfDSbW1`Eo"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":"=@8O}nLT/A+}{/vm4rdE","fields":{"NAME":"D"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"X~R6~l8[$6}pizerd2QN","fields":{"SELECTION":"Direction.CLOCKWISE"}}}},"next":{"block":{"type":"variables_set_motor","id":"sAvR(D|kYm:Tw]v6,)Vg","fields":{"VAR":{"id":"ms+~*r]DdB]t^hq]?5.o"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":"e=JcAz_R[T)`tlCqB`Id","fields":{"NAME":"A"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"LaN8|(C`BE1URNl4dedy","fields":{"SELECTION":"Direction.CLOCKWISE"}}}},"next":{"block":{"type":"variables_set_motor","id":"lZfmaD=4j]Vq{V]UlmO|","fields":{"VAR":{"id":"8)(~;Fi,SuJk[~Rf%bO5"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":"y~J`U(CFq7f(Yt!Y)Gdp","fields":{"NAME":"B"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"G=Yj5$KuFP7K2nS%{]Vj","fields":{"SELECTION":"Direction.COUNTERCLOCKWISE"}}}},"next":{"block":{"type":"variables_setup_any","id":"*{F2T}Bb.@RqxP-zY.fL","fields":{"VAR":{"id":"qx7)XWPn2R#;6.#lCF93"}},"inputs":{"VALUE0":{"shadow":{"type":"blockMathNumber","id":"iAJ.py9o7EEhqYQyRzqf","fields":{"NUM":0}}}}}}}}}}}}}}},{"type":"blockGlobalStart","id":"3tJe|AWl0baN(wH9a$@.","x":65,"y":451,"deletable":false,"next":{"block":{"type":"blockFlowWhile","id":"LFn*}]l^+q^KXk{XKjs-","fields":{"MODE":"WHILE"},"inputs":{"BOOL":{"shadow":{"type":"blockLogicTrue","id":"]s(zx2#q@Jf)cm}J8cyD"}},"DO":{"block":{"type":"blockVariableSetValue","id":"v=:Wg2#C=k(y~q-za|A#","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":"uw_@vT,*y}XpxhMbHU}]","fields":{"VAR":{"id":"qx7)XWPn2R#;6.#lCF93","name":"data","type":"Any"}}}},"VALUE0":{"shadow":{"type":"blockMathNumber","id":"2Te~~~@@6X:P+gbaM!de","fields":{"NUM":0}},"block":{"type":"blockBleObserve","id":"JDkxmv+n}-eeEsk]7cQK","fields":{"CHANNEL":"1"},"inputs":{"VAR":{"shadow":{"type":"variables_get_ble_hub","id":"m|eYTJZZ`74yTJmS/oTz","fields":{"VAR":{"id":".qW5|.{lJTGrt0ogrew^","name":"bot_hub","type":"TechnicHub"}}}}}}}},"next":{"block":{"type":"blockIfElse","id":"B1`|Y9bNE[^EO5{;KD;`","extraState":{"optionLevel":1},"inputs":{"IF0":{"shadow":{"type":"blockLogicTrue","id":"vf(z]67+_+FLO!J-{{;N"},"block":{"type":"blockLogicCompare","id":"I74-pQI~zAR-6v^$8G0(","fields":{"OP1":"NEQ"},"inputs":{"A":{"shadow":{"type":"blockMathNumber","id":"-t`-9R1$rrr@*EO9xylt","fields":{"NUM":3}},"block":{"type":"blockVariableGetValue","id":"n~Mh9T|tZ$sHHUz3;%Z@","inputs":{"VAR":{"shadow":{"type":"variables_get_any","id":"h}3O=uD,jKyl{2sr1(iq","fields":{"VAR":{"id":"qx7)XWPn2R#;6.#lCF93","name":"data","type":"Any"}}}}}}},"B":{"shadow":{"type":"blockMathNumber","id":"`mjSN$YHYd71JL7~TozC","fields":{"NUM":4}},"block":{"type":"blockNone","id":"LMbjDR)YoEj2G$QU_lEw"}}}}},"ELSE":{"block":{"type":"blockLightOnColor","id":"qxOGMTb|b7=oXGY?FRH2","extraState":{"optionLevel":1},"fields":{"METHOD":"LIGHT_ON"},"inputs":{"VAR":{"shadow":{"type":"variables_get_color_light_device","id":"{.Yo(r_/U7sM/n9j`Rj|","fields":{"VAR":{"id":".qW5|.{lJTGrt0ogrew^","name":"bot_hub","type":"TechnicHub"}}}},"COLOR":{"shadow":{"type":"variables_get_color","id":"7x]q@QnA?7rS{3;z[7Ss","fields":{"COLOUR":"#ff0000","VAR":{"id":":oqn!2~M3F?@c$t[t-v@","name":"red","type":"ColorDef"}}}}}}}}}}}}}}}}]},"variables":[{"name":"red","id":":oqn!2~M3F?@c$t[t-v@","type":"ColorDef"},{"name":"orange","id":"!Vsb!-U}WIOOVKH3nC55","type":"ColorDef"},{"name":"yellow","id":"n%@V2n^)Mh$@V/n+um-@","type":"ColorDef"},{"name":"green","id":"8;|K/%5TzxP]`BK([1tl","type":"ColorDef"},{"name":"cyan","id":"P_Z[]cHy%{Pt}qh5v[gW","type":"ColorDef"},{"name":"blue","id":"p3vC2DO8lg@onAiZcX9{","type":"ColorDef"},{"name":"violet","id":"?uKxVJ9g~pK2]^/Z.^Op","type":"ColorDef"},{"name":"magenta","id":"3c?e)G]ViW_9_od?pxd+","type":"ColorDef"},{"name":"white","id":"g@3zLA!%73Z!j,GVlbgL","type":"ColorDef"},{"name":"none","id":"p4nf{BI~aSpUZ-dX^XWB","type":"ColorDef"},{"name":"bot_hub","id":".qW5|.{lJTGrt0ogrew^","type":"TechnicHub"},{"name":"superstr_motor","id":"n74#}[-5,:EfDSbW1`Eo","type":"Motor"},{"name":"left_motor","id":"ms+~*r]DdB]t^hq]?5.o","type":"Motor"},{"name":"right_motor","id":"8)(~;Fi,SuJk[~Rf%bO5","type":"Motor"},{"name":"data","id":"qx7)XWPn2R#;6.#lCF93","type":"Any"},{"name":"light","id":"{$tVfD@+QVUYUQIjEaFF","type":"InventorHub"}],"info":{"type":"pybricks","version":"1.2.2"}}
from pybricks.hubs import TechnicHub
from pybricks.parameters import Axis, Color, Direction, Port
from pybricks.pupdevices import Motor
# Set up all devices.
bot_hub = TechnicHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[1])
superstr_motor = Motor(Port.D, Direction.CLOCKWISE)
left_motor = Motor(Port.A, Direction.CLOCKWISE)
right_motor = Motor(Port.B, Direction.COUNTERCLOCKWISE)
# Initialize variables.
data = 0
# The main program starts here.
while True:
data = bot_hub.ble.observe(1)
if data != None:
pass
else:
bot_hub.light.on(Color.RED)