Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Debut Startup")
- isopen = true
- reader = peripheral.wrap("back")
- closetest = 0
- function getTime()
- return "["..textutils.formatTime(os.time(), true).."-"..os.clock().."] "
- end
- function printer(p1)
- print(getTime()..p1)
- end
- printer("initialisation open")
- function open()
- printer("Debut Open")
- if not isopen then
- isopen = true
- rs.setOutput("top", false)
- end
- closetest = 0
- detect = true
- printer("Fin Open")
- end
- printer("initialisation close")
- function close()
- printer("Debut Close")
- if isopen then
- if closetest > 0 then
- isopen = false
- rs.setOutput("top", true)
- sleep(1.2)
- else
- closetest = 2
- end
- end
- printer("Fin Close")
- end
- printer("fin initialisation.")
- printer("fermeture de debut")
- close()
- printer("debut routine")
- while true do
- if closetest > 0 then
- closetest = closetest - 1
- end
- detect = false
- reader.scan()
- printer("New Scan")
- while true do
- printer("Wait for Event")
- event, message = os.pullEvent()
- printer("Event !")
- if event == "rfid_detected" then
- printer("rfid_detected")
- if message == "Flo18" then
- printer("rfid valide !")
- open()
- end
- elseif (event == "rfid_scan_done") then
- printer("rfid_scan_done")
- if not detect then
- printer("pas de rfid valide")
- close()
- end
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement