forked from Telos4/RoboRally
29 lines
440 B
Lua
29 lines
440 B
Lua
|
motor = {}
|
||
|
motor[1] = {}
|
||
|
motor[1][1] = 0
|
||
|
motor[1][2] = 1
|
||
|
motor[1][3] = 2
|
||
|
|
||
|
motor[2] = {}
|
||
|
motor[2][1] = 3
|
||
|
motor[2][2] = 4
|
||
|
motor[2][3] = 5
|
||
|
|
||
|
for i,m in ipairs(motor) do
|
||
|
for i,g in ipairs(m) do
|
||
|
gpio.mode(g, gpio.OUTPUT)
|
||
|
gpio.write(g, 1)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function motor_dir(m, dir)
|
||
|
if dir ~= 0 then
|
||
|
gpio.write(motor[m][3], 1)
|
||
|
gpio.write(motor[m][1], (1-dir)/2)
|
||
|
gpio.write(motor[m][2], (1+dir)/2)
|
||
|
else
|
||
|
gpio.write(motor[m][3], 0)
|
||
|
end
|
||
|
end
|
||
|
|