Advertisement
SuPeRMiNoR3

RFID Door

Jul 28th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. rfid = peripheral.wrap("back")
  2. other = peripheral.wrap("mag card reader_0")
  3. p = peripheral.wrap("bottom")
  4. data = "open_later"
  5.  
  6. function on()
  7.   rfid.setInsertCardLight(true)
  8.   other.setInsertCardLight(true)
  9. end
  10.  
  11. function off()
  12.   rfid.setInsertCardLight(false)
  13.   other.setInsertCardLight(false)
  14. end
  15.  
  16. function hash(text)              
  17.   local a = p.hash("SHA512", text)
  18.   return a
  19. end
  20.  
  21. while true do
  22.   rs.setOutput("left", true)
  23.   event,arg1,arg2,arg3 = os.pullEvent()
  24.   if event == "mag_swipe" then
  25.     if arg1 == data then
  26.     on()
  27.     sleep(0.5)
  28.     rs.setOutput("bottom", true)
  29.     sleep(0.2)
  30.     rs.setOutput("left", false)
  31.     sleep(1.5)
  32.     rs.setOutput("left", true)
  33.     sleep(0.2)
  34.     rs.setOutput("bottom", false)
  35.     sleep(1)
  36.     end
  37.   end
  38.   sleep(0.5)
  39.   off()
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement