Advertisement
CryptekCoding

RFID Door Lock

Jun 26th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. --REFID Door with automatic card creation
  2.  
  3. --configuration
  4. writer = peripheral.wrap("rfid writer_0");
  5. reader = peripheral.wrap("rfid reader_0");
  6. redside = "back";
  7.  
  8. label = "GateKey";
  9. data = "This is the gate key";
  10. range = 5;
  11.  
  12. print("Simple in-secure RFID door!");
  13. print("Key name: " .. label);
  14. print("Scanning Range " .. range);
  15.  
  16. function main()
  17. while true do
  18. --If there is a card in the writer
  19. -- and it is blank
  20. -- and we are not currently writing
  21. if writer.isPresent() and (not writer.isCoded())
  22. --make a key
  23. then writer.encode(data,label);
  24. end
  25. redstone.setOutput(redside,readerloop());
  26. os.sleep(.5); --let the redstone settle
  27. os.queueEvent("marker_event"); --clear the event
  28. repeat
  29. e = os.pullEvent();
  30. until e == "marker_event";
  31. end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement