()
| 21 | value_last = -1 |
| 22 | |
| 23 | def read_ir_keys(): |
| 24 | global value_last |
| 25 | try: |
| 26 | value = GPG.get_grove_value(GPG.GROVE_1) |
| 27 | if value != value_last: |
| 28 | value_last = value |
| 29 | if value == 1: |
| 30 | GPG.set_motor_dps(GPG.MOTOR_LEFT , 300) |
| 31 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, 300) |
| 32 | elif value == 2: |
| 33 | GPG.set_motor_dps(GPG.MOTOR_LEFT , -150) |
| 34 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, 150) |
| 35 | elif value == 4: |
| 36 | GPG.set_motor_dps(GPG.MOTOR_LEFT , 150) |
| 37 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, -150) |
| 38 | elif value == 5: |
| 39 | GPG.set_motor_dps(GPG.MOTOR_LEFT , -300) |
| 40 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, -300) |
| 41 | else: |
| 42 | GPG.set_motor_dps(GPG.MOTOR_LEFT , 0) |
| 43 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, 0) |
| 44 | except IOError or gopigo3.SensorError as e: |
| 45 | pass |
| 46 | |
| 47 | |
| 48 | print("Use the arrows on your remote controller to control your GoPiGo3") |
no test coverage detected