I am trying to change the default drive controls. I want to change it so that when I press the “A” button, the robot moves forward. Here’s the catch, I want to make it so that as long as I hold the “A” button, the robot will keep moving forward. When I let go of the “A” button, I want the robot to stop.
Here’s the code:
vexcode_brain_precision = 0
vexcode_controller_1_precision = 0
remote_control_code_enabled = None
myVariable = 0
def when_started1():
global myVariable, vexcode_brain_precision, vexcode_controller_1_precision, remote_control_code_enabled
brain.screen.print("VEXcode")
remote_control_code_enabled = True
motor_1.set_velocity(50, PERCENT)
motor_3.set_velocity(50, PERCENT)
motor_8.set_velocity(50, PERCENT)
motor_10.set_velocity(50, PERCENT)
def onevent_controller_1buttonA_pressed_0():
global myVariable, vexcode_brain_precision, vexcode_controller_1_precision, remote_control_code_enabled
while not controller_1.buttonB.pressing():
motor_1.spin(FORWARD)
motor_10.spin(REVERSE)
wait(5, MSEC)
# system event handlers
controller_1.buttonA.pressed(onevent_controller_1buttonA_pressed_0)
# add 15ms delay to make sure events are registered correctly.
wait(15, MSEC)
when_started1()
edit by mods to add code tags.