- Sun Mar 13, 2016 7:35 pm
#43051
My solution to the same problem
if(_GET.pin == "ON1")then
gpio.write(Relay1, gpio.HIGH);
timestamp = 0
tmr.alarm(0, 5000, 1, function() timestamp = timestamp + 1
if timestamp >=1 and timestamp < 2 then
gpio.write(Relay1, gpio.LOW);
gpio.write(Relay2, gpio.HIGH);
elseif timestamp >=2 and timestamp < 3 then print("2")
gpio.write(Relay2, gpio.LOW);
gpio.write(Relay3, gpio.HIGH);
elseif timestamp >=3 and timestamp < 4 then print("3")
gpio.write(Relay3, gpio.LOW);
gpio.write(Relay4, gpio.HIGH);
elseif timestamp >=4 and timestamp < 5 then print("4")
gpio.write(Relay4, gpio.LOW);
end
end )
elseif(_GET.pin == "OFF1")then
tmr.stop(0);
gpio.write(Relay1, gpio.LOW);
gpio.write(Relay2, gpio.LOW);
gpio.write(Relay3, gpio.LOW);
gpio.write(Relay4, gpio.LOW);