From fc677d38046f6c8f73d404f158c8bf0094131781 Mon Sep 17 00:00:00 2001 From: willem Date: Thu, 2 May 2024 07:16:51 +0200 Subject: [PATCH] initial --- 42100/42100_bot.py | 62 +++++++++ 42100/42100_top.py | 121 +++++++++++++++++ 42100/LR13000-XboxController.zip | Bin 0 -> 2466 bytes .../LR13000_bottom_hub_04.py | 62 +++++++++ .../LR13000_top_hub_04.py | 124 ++++++++++++++++++ 42100/Leibherr.zip | Bin 0 -> 1109 bytes 42100/Leibherr/Lower hub.py | 118 +++++++++++++++++ 42100/Leibherr/excavator_upper_hub.py | 109 +++++++++++++++ 42100/pybricks-backup-2024-05-01_18-22-08.zip | Bin 0 -> 7434 bytes .../LR13000_bottom_hub_04.py | 62 +++++++++ .../LR13000_top_hub_04.py | 121 +++++++++++++++++ .../lego4200_top_blocks.py | 3 + 12 files changed, 782 insertions(+) create mode 100644 42100/42100_bot.py create mode 100644 42100/42100_top.py create mode 100644 42100/LR13000-XboxController.zip create mode 100644 42100/LR13000-XboxController/LR13000_bottom_hub_04.py create mode 100644 42100/LR13000-XboxController/LR13000_top_hub_04.py create mode 100644 42100/Leibherr.zip create mode 100644 42100/Leibherr/Lower hub.py create mode 100644 42100/Leibherr/excavator_upper_hub.py create mode 100644 42100/pybricks-backup-2024-05-01_18-22-08.zip create mode 100644 42100/pybricks-backup-2024-05-01_18-22-08/LR13000_bottom_hub_04.py create mode 100644 42100/pybricks-backup-2024-05-01_18-22-08/LR13000_top_hub_04.py create mode 100644 42100/pybricks-backup-2024-05-01_18-22-08/lego4200_top_blocks.py diff --git a/42100/42100_bot.py b/42100/42100_bot.py new file mode 100644 index 0000000..89d200d --- /dev/null +++ b/42100/42100_bot.py @@ -0,0 +1,62 @@ +""" LEGO Liebherr LR 13000 / Xbox Controller / Pybricks + + Top hub connects to Xbox controller. + + Bottom hub receives the control data from the top one. + + Controls: + Undercarriage + Left track forward ... Left trigger + Left track backward ... Left trigger + Button X pushed + Right track forward ... Right trigger + Right track backward ... Right trigger + Button A pushed + The superstructure turning ... Right joystick left / right + Crane + The boom raising / lowering ... Left joystick up / down + The jib raising / lowering ... Left joystick left / right + The hook raising / lowering ... Right joystick up / down + The lights on / off ... Button Y +""" + +from pybricks.hubs import TechnicHub +from pybricks.pupdevices import Motor, Light +from pybricks.parameters import Button, Color, Direction, Port +from pybricks.tools import wait +from pybricks.iodevices import XboxController + +hub = TechnicHub(observe_channels=[1]) +superstr_motor = Motor(Port.D, positive_direction=Direction.COUNTERCLOCKWISE) +left_motor = Motor(Port.A, positive_direction=Direction.CLOCKWISE) +right_motor = Motor(Port.B, positive_direction=Direction.COUNTERCLOCKWISE) + +# motors settings +LEFT_TRACK_SPEED = 800 +RIGHT_TRACK_SPEED = 800 +ROTATESPEED = 240 # motor speed to turn the crane superstructure + +while True: + + # Receive broadcast from the other hub. + data = hub.ble.observe(1) + + if data is None: + # No data has been received in the last 1 second. + hub.light.on(Color.RED) + else: + # Data was received and is less that one second old. + hub.light.on(Color.GREEN) + + # *data* contains the same values in the same order + # that were passed to hub.ble.broadcast() on the + # other hub. + rot_speed, left_tr_speed, right_tr_speed = data + + # control of the superstructure turning + superstr_motor.run(rot_speed * ROTATESPEED / 80) + + # left track control + left_motor.run(left_tr_speed * LEFT_TRACK_SPEED / 100) + + # right track control + right_motor.run(right_tr_speed * RIGHT_TRACK_SPEED / 100) + diff --git a/42100/42100_top.py b/42100/42100_top.py new file mode 100644 index 0000000..04539a6 --- /dev/null +++ b/42100/42100_top.py @@ -0,0 +1,121 @@ +""" LEGO Liebherr LR 13000 / Xbox Controller / Pybricks + + Top hub connects to Xbox controller. + + Bottom hub receives the control data from the top one. + + Controls: + Undercarriage + Left track forward ... Left trigger + Left track backward ... Left trigger + Button X pushed + Right track forward ... Right trigger + Right track backward ... Right trigger + Button A pushed + The superstructure turning ... Right joystick left / right + Crane + The boom raising / lowering ... Left joystick up / down + The jib raising / lowering ... Left joystick left / right + The hook raising / lowering ... Right joystick up / down + The lights on / off ... Button Y +""" + +from pybricks.hubs import TechnicHub +from pybricks.pupdevices import Motor, Light +from pybricks.parameters import Button, Color, Direction, Port +from pybricks.tools import wait +from pybricks.iodevices import XboxController + +hub = TechnicHub(broadcast_channel=1) +controller = XboxController() +boom_motor = Motor(Port.A, positive_direction=Direction.COUNTERCLOCKWISE) +arm_motor = Motor(Port.B, positive_direction=Direction.COUNTERCLOCKWISE) +bucket_motor = Motor(Port.C, positive_direction=Direction.CLOCKWISE) +scoop_motor = Motor(Port.D, positive_direction=Direction.CLOCKWISE) + +# motors settings +BOOMSPEED = 1000 +BUCKETSPEED = 100 +ARMSPEED = 1000 +SCOOPSPEED = 1000 + +hub.light.on(Color.GREEN) + +while True: + + + # control of the boom raising and lowering + boom_speed = 0 + horizontal, vertical = controller.joystick_left() + if vertical < -20: + boom_speed = vertical + 20 + elif vertical > 20: + boom_speed = vertical - 20 + + boom_motor.run(boom_speed * BOOMSPEED / 80) + + # control of the jib raising and lowering + bucket_speed = 0 + horizontal, vertical = controller.joystick_left() + if horizontal < -20: + bucket_speed = horizontal + 20 + elif horizontal > 20: + bucket_speed = horizontal - 20 + + bucket_motor.run(bucket_speed * BUCKETSPEED / 80) + + # control of arm + arm_speed = 0 + horizontal, vertical = controller.joystick_right() + if vertical < -20: + arm_speed = vertical + 20 + elif vertical > 20: + arm_speed = vertical - 20 + + arm_motor.run(arm_speed * ARMSPEED / 80) + + # control of scoop + scoop_speed = 0 + horizontal, vertical = controller.joystick_right() + if horizontal < -20: + scoop_speed = vertical + 20 + elif horizontal > 20: + scoop_speed = vertical - 20 + + scoop_motor_motor.run(scoop_speed * SCOOPSPEED / 80) + + # control of the superstructure turning + rot_speed = 0 + now_pressed = controller.buttons.pressed() + if controller.button.RIGHT: + rot_speed = ROTATESPEED + elif controller.button.LEFT: + rot_speed = -ROTATESPEED + + + + # left track control + left_tr_speed = 0 + now_pressed = controller.buttons.pressed() + if "X" in now_pressed: + brake, acceleration = controller.triggers() + if brake > 10: + left_tr_speed -= brake + else: + brake, acceleration = controller.triggers() + if brake > 10: + left_tr_speed += brake + + # right track control + right_tr_speed = 0 + now_pressed = controller.buttons.pressed() + if "A" in now_pressed: + brake, acceleration = controller.triggers() + if acceleration > 10: + right_tr_speed -= acceleration + else: + brake, acceleration = controller.triggers() + if acceleration > 10: + right_tr_speed += acceleration + + # Set the broadcast data and start broadcasting if not already doing so. + data = (rot_speed, left_tr_speed, right_tr_speed) + hub.ble.broadcast(data) diff --git a/42100/LR13000-XboxController.zip b/42100/LR13000-XboxController.zip new file mode 100644 index 0000000000000000000000000000000000000000..d0815a64f644fc4df8414b09b7fa5db452e1d1ef GIT binary patch literal 2466 zcmai0c{CJi8y`D`B+DQ}GRiWHhHyt$HAzM^7>p&$n6WRzi0sEUW8X#Dld)ZU`fL#~ zjc&QNu_xRRLW{tL^FtZ1u?qpdF4cS-=I_Vh zC3+CAo2bH|P$&e0^}dbp_VV-f_VB>_s-O;&xB=XGILy9qKUs$j065PL0I2*p>9Cd^ z*4xj|+tbeF7S;}`rc4OTGBZpWh6-F5>%_8Wi&PGmwGQ%72+AE(W54Th?(UNl+j*5zP>Ufq zvpeN|zMo)pnKt!AmJ4x}MdhZn%*-51HgokHC3~6k_EAUi)vce3#bH8Q*NQp(9a4$E zJCw-xSVHO*;?l<6zIkcD{A|2f4y$RJwZ^eITg_7=>Dp~ENki}&V(k5LSi+jfXMKBQ zZDZPdpt2j%yxY0l&D4Iz-U4f#XUxN}rKsnxs3n^gTU>HUMSZ5!pd_kRUyO=J*qYGR zKwSZ!hcTDll>WZQ zU6!QGbCniCsMCHg7;a*fBSjt0ZkZFrYlmKR7Q5N0YbRrsQTr#$2j7>HYcx@!DGkq zb7A?vWzeg3+CGzWHEmOS68fU6XKXvP+&hhI!9LD`yCJM|t}R{YSS^T{j@3)?`-55_ zZK{9F+2evY|1_YAN18RZOVi_*#55k+S;gB zRF)@NcDc<*c=}@e*{LLb`2@MCp=G1xXqVtcWAdg+SgZ_~+~HVa)(#BRQU4=?+RgLs znlyo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Controller/LR13000_bottom_hub_04.py new file mode 100644 index 0000000..44e22e5 --- /dev/null +++ b/42100/LR13000-XboxController/LR13000_bottom_hub_04.py @@ -0,0 +1,62 @@ +""" LEGO Liebherr LR 13000 / Xbox Controller / Pybricks + + Top hub connects to Xbox controller. + + Bottom hub receives the control data from the top one. + + Controls: + Undercarriage + Left track forward ... Left trigger + Left track backward ... Left trigger + Button X pushed + Right track forward ... Right trigger + Right track backward ... Right trigger + Button A pushed + The superstructure turning ... Right joystick left / right + Crane + The boom raising / lowering ... Left joystick up / down + The jib raising / lowering ... Left joystick left / right + The hook raising / lowering ... Right joystick up / down + The lights on / off ... Button Y +""" + +from pybricks.hubs import TechnicHub +from pybricks.pupdevices import Motor, Light +from pybricks.parameters import Button, Color, Direction, Port +from pybricks.tools import wait +from pybricks.iodevices import XboxController + +hub = TechnicHub(observe_channels=[1]) +superstr_motor = Motor(Port.B, positive_direction=Direction.COUNTERCLOCKWISE) +left_motor = Motor(Port.C, positive_direction=Direction.CLOCKWISE) +right_motor = Motor(Port.D, positive_direction=Direction.COUNTERCLOCKWISE) + +# motors settings +LEFT_TRACK_SPEED = 800 +RIGHT_TRACK_SPEED = 800 +ROTATESPEED = 240 # motor speed to turn the crane superstructure + +while True: + + # Receive broadcast from the other hub. + data = hub.ble.observe(1) + + if data is None: + # No data has been received in the last 1 second. + hub.light.on(Color.RED) + else: + # Data was received and is less that one second old. + hub.light.on(Color.GREEN) + + # *data* contains the same values in the same order + # that were passed to hub.ble.broadcast() on the + # other hub. + rot_speed, left_tr_speed, right_tr_speed = data + + # control of the superstructure turning + superstr_motor.run(rot_speed * ROTATESPEED / 80) + + # left track control + left_motor.run(left_tr_speed * LEFT_TRACK_SPEED / 100) + + # right track control + right_motor.run(right_tr_speed * RIGHT_TRACK_SPEED / 100) + diff --git a/42100/LR13000-XboxController/LR13000_top_hub_04.py b/42100/LR13000-XboxController/LR13000_top_hub_04.py new file mode 100644 index 0000000..ee3a608 --- /dev/null +++ b/42100/LR13000-XboxController/LR13000_top_hub_04.py @@ -0,0 +1,124 @@ +""" LEGO Liebherr LR 13000 / Xbox Controller / Pybricks + + Top hub connects to Xbox controller. + + Bottom hub receives the control data from the top one. + + Controls: + Undercarriage + Left track forward ... Left trigger + Left track backward ... Left trigger + Button X pushed + Right track forward ... Right trigger + Right track backward ... Right trigger + Button A pushed + The superstructure turning ... Right joystick left / right + Crane + The boom raising / lowering ... Left joystick up / down + The jib raising / lowering ... Left joystick left / right + The hook raising / lowering ... Right joystick up / down + The lights on / off ... Button Y +""" + +from pybricks.hubs import TechnicHub +from pybricks.pupdevices import Motor, Light +from pybricks.parameters import Button, Color, Direction, Port +from pybricks.tools import wait +from pybricks.iodevices import XboxController + +hub = TechnicHub(broadcast_channel=1) +controller = XboxController() +boom_motor = Motor(Port.A, positive_direction=Direction.COUNTERCLOCKWISE) +hook_motor = Motor(Port.B, positive_direction=Direction.COUNTERCLOCKWISE) +jib_motor = Motor(Port.D, positive_direction=Direction.CLOCKWISE) +light = Light(Port.C) + +# motors settings +BOOMSPEED = 700 +JIBSPEED = 700 +HOOKSPEED = 800 + +light.off() +light_on = False + +hub.light.on(Color.GREEN) + +while True: + + # Lights on/off + now_pressed = controller.buttons.pressed() + if "Y" in now_pressed: + if light_on: + light.off() + light_on = False + wait(10) + else: + light.on(100) + light_on = True + wait(10) + while "Y" in controller.buttons.pressed(): # wait until released + wait(10) + + # control of the boom raising and lowering + boom_speed = 0 + horizontal, vertical = controller.joystick_left() + if vertical < -20: + boom_speed = vertical + 20 + elif vertical > 20: + boom_speed = vertical - 20 + + boom_motor.run(boom_speed * BOOMSPEED / 80) + + # control of the jib raising and lowering + jib_speed = 0 + horizontal, vertical = controller.joystick_left() + if horizontal < -20: + jib_speed = horizontal + 20 + elif horizontal > 20: + jib_speed = horizontal - 20 + + jib_motor.run(jib_speed * JIBSPEED / 80) + + # control of the hook raising and lowering + hook_speed = 0 + horizontal, vertical = controller.joystick_right() + if vertical < -20: + hook_speed = vertical + 20 + elif vertical > 20: + hook_speed = vertical - 20 + + hook_motor.run(hook_speed * HOOKSPEED / 80) + + # control of the superstructure turning + rot_speed = 0 + horizontal, vertical = controller.joystick_right() + if horizontal < -20: + rot_speed = horizontal + 20 + elif horizontal > 20: + rot_speed = horizontal - 20 + + # left track control + left_tr_speed = 0 + now_pressed = controller.buttons.pressed() + if "X" in now_pressed: + brake, acceleration = controller.triggers() + if brake > 10: + left_tr_speed -= brake + else: + brake, acceleration = controller.triggers() + if brake > 10: + left_tr_speed += brake + + # right track control + right_tr_speed = 0 + now_pressed = controller.buttons.pressed() + if "A" in now_pressed: + brake, acceleration = controller.triggers() + if acceleration > 10: + right_tr_speed -= acceleration + else: + brake, acceleration = controller.triggers() + if acceleration > 10: + right_tr_speed += acceleration + + # Set the broadcast data and start broadcasting if not already doing so. + data = (rot_speed, left_tr_speed, right_tr_speed) + hub.ble.broadcast(data) diff --git a/42100/Leibherr.zip b/42100/Leibherr.zip new file mode 100644 index 0000000000000000000000000000000000000000..2e43badd292eec9e30d052e91cdf9fc2f6a909a3 GIT binary patch literal 1109 zcmWIWW@Zs#U|`^2c(-w0aE;EnnnjEZ43k(H7{q|0sTIkIWr-#EMe(Ht1*t{x8Kp^j z1(mInW3!tLBwF9I{&#+%*Rxpo_9=>`|Y|`YWE7k zBTwdhepYFEZ*Ohh!Me?rcbmS}WlFKT2|4I99)8$qeO%`OgZdN$#xf0?Wfn2%2iJC| znKiK*;WBB#mLpq#ze!G%3im#yzx9A? z%jGKBqZ%SpT|8x;OWx#+(6Dv5ZQ}PrNMOEe(23kvlMY|tekxx%NYP^N)Fb$6g<-f5XM|xZ3K^v88`P zME75RmLH#0S{i5blId<@?96RJD|d-r{=pmok5#>`^MWNF{M&jE7^|{u3=BNLSoO&- zPc2e_#O2)J*z7|FBDMNo>{-4iSg#6^sFrw>n8%zrx%cIb$1C1mWy==M3p!fAf5}$U zzd~tDOLsoMQ*2*U{Q2L<&%a#L?g!tFQob!%7o*6#JxL~A+wn!8@st$K#5tD=rmdZ& zGw&nEH-0&AnID;W$`ly2?=AmTk)kO1{e-c%gjuXgvgc7dmXKT5Iwy4|vvNpY z+_K4;X`zndxk)a+S9qOR9N7H$)-|y{ZLx$U48F#`$t}F1TA}LK%eJ~OW&hMRJPt`e?tK5*Gs}-@ zS7%+No%y0IBHyQ(>#E;>HuKBU`i!MPck^t;_pUlEw{_#ZAlLnM?Ht#Vzh|&r&+OCd zatk+ov?%3&#-DnXm`Xj{Z1VQ3dep7ki<5Z*KXXdIU-vX_#;nH|CYZjA-Tm&4 zYOuT4meWbm^#R_DOd<@pvoJ8e85kK9Kok&Q&(O$bU`sF{oe(pw0h1AO@(J)}1tuy6 O1|}e^1JVbXK|BDnci0I4 literal 0 HcmV?d00001 diff --git a/42100/Leibherr/Lower hub.py b/42100/Leibherr/Lower hub.py new file mode 100644 index 0000000..b025815 --- /dev/null +++ b/42100/Leibherr/Lower hub.py @@ -0,0 +1,118 @@ +#LOWER HUB +from pybricks.hubs import TechnicHub +from pybricks.pupdevices import Motor +from pybricks.parameters import Port, Stop, Color +from pybricks.tools import wait + +from usys import stdin +from uselect import poll + +hub = TechnicHub() +keyboard = poll() +keyboard.register(stdin) + +left_track = Motor(Port.A) +right_track = Motor(Port.B) +turret = Motor(Port.D) + +lSpeed = 0 +rSpeed = 0 + + +def trackMove(lSpeed, rSpeed): + left_track.run(speed = lSpeed) + right_track.run(speed = rSpeed) + + + + +while True: + if keyboard.poll(0): + + + key = stdin.read(1) + print("Key pressed", key) + + if key in('4'): + key1 = 1000 + elif key in('6'): + key1 = -1000 + else: + key1 = 0 + + + + + turret.run(key1 * 1000) + + if key in('w'): + lSpeed = 1000 + rSpeed = -1000 + + elif key in('s'): + lSpeed = -1000 + rSpeed = 1000 + + elif key in('a'): + lSpeed = -1000 + rSpeed = -1000 + + elif key in('d'): + lSpeed = 1000 + rSpeed = 1000 + + elif key in('4'): + key1 = 1 + elif key in('6'): + key1 = -1 + + else: + lSpeed = 0 + rSpeed = 0 + + + + + + + + + trackMove(lSpeed,rSpeed) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/42100/Leibherr/excavator_upper_hub.py b/42100/Leibherr/excavator_upper_hub.py new file mode 100644 index 0000000..4fc7db0 --- /dev/null +++ b/42100/Leibherr/excavator_upper_hub.py @@ -0,0 +1,109 @@ +#FOR UPPER HUB +from pybricks.hubs import TechnicHub +from pybricks.pupdevices import Motor +from pybricks.parameters import Port, Stop, Color +from pybricks.tools import wait + +from usys import stdin +from uselect import poll + +hub = TechnicHub() +keyboard = poll() +keyboard.register(stdin) + + +boom_motor = Motor(Port.A) +arm_motor = Motor(Port.B) +bucket_motor = Motor(Port.C) +scoop_motor = Motor(Port.D) + +while True: + if keyboard.poll(0): + + + key = stdin.read(1) + print("Key pressed", key) + + if key in ('w'): + key1 = 1 + elif key in('s'): + key1 = -1 + else: + key1 = 0 + + boom_motor.run(key1 * 1000) + + if key in('a'): + key2 = 1 + elif key in('d'): + key2 = -1 + else: + key2 = 0 + + + + arm_motor.run(key2 * 1000) + + + if key in('8'): + key3 = 1 + elif key in('2'): + key3 = -1 + else: + key3 = 0 + + + + bucket_motor.run(key3 * 1000) + + + if key in('4'): + key4 = 1 + elif key in('6'): + key4 = -1 + else: + key4 = 0 + + + + + scoop_motor.run(key4 * 1000) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/42100/pybricks-backup-2024-05-01_18-22-08.zip b/42100/pybricks-backup-2024-05-01_18-22-08.zip new file mode 100644 index 0000000000000000000000000000000000000000..9936b1367283520a7c74674e1197e99954d9ddc7 GIT binary patch literal 7434 zcmeHMTXW*b6?U?lRIF6xVJo+XJhbsl4PYz_JXdzvS-`A4i)}E*V>?q5wuKrH$ZBm% zfEiz&@|dSo{=oi*{Dr)x@|?esm%Qe5wb zBaET_1`?!b3!Ulo5|yd#F=|v`07}CqoAIFzPURAx1rrN^PP_9lm-uFEpOm24QW?n2EbYS>;CT zla7ZxhT8+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;m>*A@U z>G&`?-g|)`e5S@F!~24H$(e*rE7Jdb0W~H_-e0)op@L&o%b@>phtBS1!73JEW7~u=~sudWu~V@VB2FRqf5!mq%y) zv$0mMoSj}hxSM~%tsMvaU*zl?=iScc#`dUjSS-`Mo8tA|{9OjU!+>2&9@g#M((}@K z?x>&MHV(cz=-mVSDBOH)@b2c7NQ>*3wnFCg0Bwh{>F*|qV<^-d?h zo?okxKB<(BxPRQScW{*g-}K$y{)ts6G$At?fe^+z?-Bsi;+J!e4 zGJCoR+R*Uo%;9mEd^GFxk9eB<(T{(*viwCMRKn7A`4Z&Fv fvl(|P; 20: + # boom_speed = vertical - 20 + + # boom_motor.run(boom_speed * BOOMSPEED / 80) + + # # control of the jib raising and lowering + # bucket_speed = 0 + # horizontal, vertical = controller.joystick_left() + # if horizontal < -20: + # bucket_speed = horizontal + 20 + # elif horizontal > 20: + # bucket_speed = horizontal - 20 + + # bucket_motor.run(bucket_speed * BUCKETSPEED / 80) + + # # control of arm + # arm_speed = 0 + # horizontal, vertical = controller.joystick_right() + # if vertical < -20: + # arm_speed = vertical + 20 + # elif vertical > 20: + # arm_speed = vertical - 20 + + # arm_motor.run(arm_speed * ARMSPEED / 80) + + # # control of scoop + # scoop_speed = 0 + # horizontal, vertical = controller.joystick_right() + # if horizontal < -20: + # scoop_speed = vertical + 20 + # elif horizontal > 20: + # scoop_speed = vertical - 20 + + # scoop_motor_motor.run(scoop_speed * SCOOPSPEED / 80) + + # control of the superstructure turning + rot_speed = 0 + now_pressed = controller.buttons.pressed() + if controller.button.RIGHT: + rot_speed = ROTATESPEED + elif controller.button.LEFT: + rot_speed = ROTATESPEED * -1 + + + + # left track control + left_tr_speed = 0 + now_pressed = controller.buttons.pressed() + if "X" in now_pressed: + brake, acceleration = controller.triggers() + if brake > 10: + left_tr_speed -= brake + else: + brake, acceleration = controller.triggers() + if brake > 10: + left_tr_speed += brake + + # right track control + right_tr_speed = 0 + now_pressed = controller.buttons.pressed() + if "A" in now_pressed: + brake, acceleration = controller.triggers() + if acceleration > 10: + right_tr_speed -= acceleration + else: + brake, acceleration = controller.triggers() + if acceleration > 10: + right_tr_speed += acceleration + + # Set the broadcast data and start broadcasting if not already doing so. + data = (rot_speed, left_tr_speed, right_tr_speed) + hub.ble.broadcast(data) diff --git a/42100/pybricks-backup-2024-05-01_18-22-08/lego4200_top_blocks.py b/42100/pybricks-backup-2024-05-01_18-22-08/lego4200_top_blocks.py new file mode 100644 index 0000000..650531a --- /dev/null +++ b/42100/pybricks-backup-2024-05-01_18-22-08/lego4200_top_blocks.py @@ -0,0 +1,3 @@ +# pybricks blocks file:{"blocks":{"languageVersion":0,"blocks":[{"type":"blockGlobalSetup","id":"bjK,wS1MYO7aiYkFSwd{","x":150,"y":100,"deletable":false},{"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!"}}}}}}}]},"variables":[{"name":"red","id":"b(K72kbjLK3eaWY0rZ|H","type":"ColorDef"},{"name":"orange","id":"c5QKn-VxQXjXw0PEXW{$","type":"ColorDef"},{"name":"yellow","id":"J2n}pzD-+3vRNACoH}A|","type":"ColorDef"},{"name":"green","id":"0(NPnGB8B#2Qj*3dMqMj","type":"ColorDef"},{"name":"cyan","id":"`cTjOq2c5Qt!:AB0MNE~","type":"ColorDef"},{"name":"blue","id":")~d23yr%3gimljv:M!%H","type":"ColorDef"},{"name":"violet","id":".;6s97*6~~o){?kf32Vu","type":"ColorDef"},{"name":"magenta","id":"hnOw;Pff:#:!OejeEBQ8","type":"ColorDef"},{"name":"white","id":"|u=R}I%9QzW(~|dUY+U}","type":"ColorDef"},{"name":"none","id":"*c=-CgnIE*K6T9Gxk[8}","type":"ColorDef"}],"info":{"type":"pybricks","version":"1.2.2"}} +# The main program starts here. +print('Hello, Pybricks!')