Example - servo control
Posted: Tue Dec 09, 2014 4:18 pm
In this example e servo is controlled via a UDP server.
I send commands from my phone UDPtester app
Forexample 1500 means the servo is in neutral and 1000 and 2000 to either side
For those who don't know:
The signal til control a servo is a pulse between 1000 and 2000 uS, sendt every 20 ms.
The servo seems a little "twichy" which I think is because of the GPIO Flicker mentioned here:
viewtopic.php?f=18&t=781
Don't send values outside 1000 to 2000, the servo might be damaged.
It would be more useful if I had a UDP sender with a knob or slider.
Anybody know of an androis app ?
I send commands from my phone UDPtester app
Forexample 1500 means the servo is in neutral and 1000 and 2000 to either side
For those who don't know:
The signal til control a servo is a pulse between 1000 and 2000 uS, sendt every 20 ms.
The servo seems a little "twichy" which I think is because of the GPIO Flicker mentioned here:
viewtopic.php?f=18&t=781
Don't send values outside 1000 to 2000, the servo might be damaged.
It would be more useful if I had a UDP sender with a knob or slider.
Anybody know of an androis app ?
Code: Select all
if(pl==nil) then
pl=1500
end
port=88
pin=9
srv=net.createServer(net.UDP)
srv:on("receive", function(srv, pl)
print("Command Reveived")
print(pl)
--servo code
gpio.mode(pin,gpio.OUTPUT)
tmr.alarm(20, 1, function()
gpio.write(pin,gpio.HIGH)
tmr.delay(pl)
gpio.write(pin,gpio.LOW)
end)
--servo code
end)
srv:listen(port)