Using IR remote To Move The Robot
Receiving codes for Yahboom's IR remote:
left | middle | right |
---|---|---|
0x00 |
0x01 |
0x02 |
0x03 |
0x04 |
0x05 |
0x06 |
0x07 |
0x08 |
0x09 |
0x0a |
0x0b |
0x0c |
0x0d |
0x0e |
0x0f |
0x10 |
0x11 |
0x12 |
0x13 |
0x14 |
0x15 |
0x16 |
0x17 |
0x18 |
0x19 |
0x1a |
Code
import sys
sys.path.append("/path/to/library/")
from McLumk_Wheel_Sports import *
bot = Raspbot()
read_ir_code = lambda : bot.read_data_array(0x0C, 1)
SPEED = 200
ir_code_to_movement= [
move_diagonal_left_front, #0x00
move_forward, #0x01
move_diagonal_right_front, #0x02
move_left, #0x03
stop_robot, #0x04
move_right, #0x05
move_diagonal_left_back, #0x06
move_backward, #0x07
move_diagonal_right_back, #0x08
rotate_left, #0x09
stop, #0x10
rotate_left, #0x11
]
try:
SHIFT_INDEX = 3
while True:
bot.Ctrl_IR_Switch(1)
if (ir_code:=read_ir_code) in list(range(shift_index, len(ir_code_to_movement))):
ir_code_to_movement[ir_code-SHIFT_INDEX](SPEED)
else:
stop_robot()
except:
bot.Ctrl_IR_Switch(0)
stop_robot()