PDA

View Full Version : Multiple GPIO input with the same timer



jeanclaudej971
May 2nd, 2017, 08:34 PM
Hello
I found this script used to detect a lighted TV or nipple.


raspi = require("raspi")

raspi.export( 24 )
raspi.direction( 24, false )

rpidoor = {}
rpidoor.enabled = false

print("RPI IO Enabled.")

rpidoor.timer = timer.new( 100, function()

local pin = raspi.read( 24 ) ~= 0

-- disable this line once it all works.
print("Periodic DOOR Check", pin)

if pin ~= rpidoor.enabled then
if pin then
gir.triggerEvent("DOOR open", 18, Promixis.Event.MOD_ON, payload)
else
gir.triggerEvent("DOOR closed", 18, Promixis.Event.MOD_ON, payload)
end
rpidoor.enabled = pin
end



end)

rpidoor.timer:start()



It works perfectly, but I would like to use it to scan several GPIO inputs with open door detectors or close with the same time delay so as not to saturate the R pie.
Would it be possible to export and give direction to several entries at the same time?
Could you help me edit the script for GPIO24 and 25 for example?

regards
Jean Claude