v0.2.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
################################################################################
|
||||
# #
|
||||
# pybricks script for 42109 - RC Truck v.3 by ufotografol #
|
||||
# pybricks script for 42109-1 - App-Controlled Top Gear Rally Car #
|
||||
# #
|
||||
# This script enables the LEGO® Powered Up Technic Hub to be used with the #
|
||||
# LEGO® Powerd UP 88010 Remote. #
|
||||
@@ -12,14 +12,25 @@
|
||||
# Port D: Drive motor #
|
||||
# #
|
||||
################################################################################
|
||||
# Rebrickable: https://rebrickable.com/mocs/MOC-57612/ #
|
||||
# Script base: https://racingbrick.com/2021/08/remote-control-for-control-sets #
|
||||
# -without-an-app-or-smartphone-pybricks/ #
|
||||
################################################################################
|
||||
# #
|
||||
# Works with the following MOCs #
|
||||
# #
|
||||
################################################################################
|
||||
# 42109 - RC Truck v.3 by ufotografol #
|
||||
# https://rebrickable.com/mocs/MOC-57612/ #
|
||||
# Off-road racing car (42109) by ConstructionsByDonat #
|
||||
# https://rebrickable.com/mocs/MOC-90323/ #
|
||||
################################################################################
|
||||
# #
|
||||
# Changelog #
|
||||
# #
|
||||
################################################################################
|
||||
# v0.2.0 02-07-2022 #
|
||||
# 2 speed "gearbox" changed to 3 speed, recodingwith debounce and now left #
|
||||
# button also used. #
|
||||
# v0.1.0 15-06-2022 #
|
||||
# 2 speed "gearbox" added. #
|
||||
# v0.0.1 15-06-2022 #
|
||||
@@ -62,26 +73,53 @@ steering.run_target(speed=200, target_angle=0, wait=False)
|
||||
steer_angle = (((right_end - left_end)/2)-5)
|
||||
|
||||
# Set variable for gear
|
||||
gear_old = 1
|
||||
gear = 1
|
||||
speed = 50
|
||||
speed = 33
|
||||
|
||||
while True:
|
||||
# Check which buttons are pressed.
|
||||
pressed = remote.buttons.pressed()
|
||||
|
||||
# Check if the right middle button is pressed to change gear and set the
|
||||
# speed accordingly.
|
||||
# Check if the right middle button is pressed to change gear
|
||||
if Button.RIGHT in pressed:
|
||||
if gear is 1:
|
||||
remote.light.on(Color.RED)
|
||||
if gear_old is 1:
|
||||
gear = 2
|
||||
speed = 100
|
||||
wait(100)
|
||||
elif gear_old is 2:
|
||||
gear = 3
|
||||
else:
|
||||
remote.light.on(Color.BLUE)
|
||||
gear = 1
|
||||
speed = 50
|
||||
wait(100)
|
||||
while Button.RIGHT in pressed:
|
||||
# Button debounce
|
||||
wait(10)
|
||||
pressed = remote.buttons.pressed()
|
||||
|
||||
# Check if the left middle button is pressed to change gear
|
||||
if Button.LEFT in pressed:
|
||||
if gear_old is 3:
|
||||
gear = 2
|
||||
elif gear_old is 2:
|
||||
gear = 1
|
||||
else:
|
||||
gear = 3
|
||||
while Button.LEFT in pressed:
|
||||
# Button debounce
|
||||
wait(10)
|
||||
pressed = remote.buttons.pressed()
|
||||
|
||||
if gear is not gear_old:
|
||||
if gear is 1:
|
||||
remote.light.on(Color.BLUE)
|
||||
speed = 33
|
||||
gear_old = 1
|
||||
elif gear is 2:
|
||||
remote.light.on(Color.WHITE)
|
||||
speed = 67
|
||||
gear_old = 2
|
||||
else:
|
||||
remote.light.on(Color.RED)
|
||||
speed = 100
|
||||
gear_old = 3
|
||||
|
||||
# Choose the steering angle based on the right controls.
|
||||
if Button.RIGHT_PLUS in pressed:
|
||||
@@ -100,4 +138,4 @@ while True:
|
||||
driving.dc(0)
|
||||
|
||||
# Wait.
|
||||
wait(10)
|
||||
wait(10)
|
||||
|
||||
Reference in New Issue
Block a user