from hub2hub import Remote, ble_handler from hub import port from time import sleep_ms #Lib: https://hub2hub.readthedocs.io/en/latest/ ble = ble_handler() Remote = Remote(ble) led_direction = 0 led_brightness = 0 remode = 0 Remote.connect() #A: motor_left #B: motor_right #C: arm1 #D: Lights1 #E: arm2 #F: Lights2 port.F.pwm(100) Remote.led(1) while True: if remode == 0: if Remote.right.plus.is_pressed(): port.A.pwm(70) elif Remote.right.min.is_pressed(): port.A.pwm(-70) else: port.A.pwm(0) if Remote.left.plus.is_pressed(): port.B.pwm(70) elif Remote.left.min.is_pressed(): port.B.pwm(-70) else: port.B.pwm(0) else: if Remote.right.plus.is_pressed(): port.C.pwm(70) elif Remote.right.min.is_pressed(): port.C.pwm(-70) else: port.C.pwm(0) if Remote.left.plus.is_pressed(): port.E.pwm(100) elif Remote.left.min.is_pressed(): port.E.pwm(-100) else: port.E.pwm(0) if led_brightness >= 100: led_direction = 1 if led_brightness <= 0: led_direction = 0 if led_direction == 0: led_brightness = led_brightness+1 else: led_brightness = led_brightness-1 port.D.pwm(led_brightness) if Remote.right.red.is_pressed(): remode = 1 Remote.led(2) sleep_ms(100) if Remote.left.red.is_pressed(): remode = 0 Remote.led(1) sleep_ms(100) sleep_ms(10)