Using IR remote To Move The Robot
Receiving codes for Yahboom's IR remote:
| left | middle | right |
|---|---|---|
0x00 |
0x01 |
0x02 |
0x04 |
0x05 |
0x06 |
0x08 |
0x09 |
0x0A |
0x0C |
0x0D |
0x0E |
0x10 |
0x11 |
0x12 |
0x14 |
0x15 |
0x16 |
0x18 |
0x19 |
0x1A |
Code
import sys
sys.path.append("/path/to/library/")
from McLumk_Wheel_Sports import *
read_ir_code = lambda : bot.read_data_array(0x0C, 1)
SPEED = 75
ir_code_to_movement= [
move_diagonal_left_front, #0x00
move_forward, #0x01
move_diagonal_right_front, #0x02
move_left, #0x03
lambda x: stop_robot, #0x04
move_right, #0x05
move_diagonal_left_back, #0x06
move_backward, #0x07
move_diagonal_right_back, #0x08
rotate_left, #0x09
lambda x: stop(), #0x10
rotate_right, #0x11
]
try:
map_number = lambda x: int(x - x//4)
SHIFT_INDEX = 0
while True:
bot.Ctrl_IR_Switch(1)
time.sleep(0.01)
if (ir_code_mapped:=map_number(read_ir_code()[0])) in range(len(ir_code_to_movement)):
print(ir_code_mapped)
ir_code_to_movement[ir_code_mapped](SPEED)
else:
stop_robot()
except Exception as e:
bot.Ctrl_IR_Switch(0)
stop_robot()
print(e)