MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / read_ir_keys

Function read_ir_keys

Software/Python/Examples/Remote_Control.py:23–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21value_last = -1
22
23def 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
48print("Use the arrows on your remote controller to control your GoPiGo3")

Callers 1

Remote_Control.pyFile · 0.85

Calls 2

get_grove_valueMethod · 0.45
set_motor_dpsMethod · 0.45

Tested by

no test coverage detected