Guest User

lol

a guest
May 6th, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.90 KB | None | 0 0
  1. function clear()
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. end
  5.  
  6. s = peripheral.wrap("back") --speaker
  7. w = peripheral.wrap("top")  --rfid writer
  8. r = peripheral.wrap("right")--rfid reader
  9. m = peripheral.wrap("left") --magcard
  10.  
  11. function sdb(db)
  12. s.setAttenuation(db)
  13. end
  14.  
  15. while true do
  16. print("chose option 1,2,3,4 or 5 \n[1] write a RFID card\n[2] read all RFID cards in range\n[3] write code on a magcard\n[4] read the code of a magcard\n[5] exit")
  17. num=tonumber(read())
  18. if num == 1 then
  19.    if w.isPresent() == true then
  20.       print("enter a code for your RFID card")
  21.       c=read()
  22.       print("now enter a label")
  23.       l=read()
  24.       print("encoding...")
  25.       w.encode(tostring(c),tostring(l))
  26.       sdb(10)
  27.       s.start(2,200)
  28.       os.pullEvent("rfid_written")
  29.       print("done!\nplease take out your card")
  30.       s.stop(2)
  31.       sdb(0)
  32.       s.start(1,400)
  33.       sleep(1)
  34.       s.stop(1)
  35.       clear()
  36.     else
  37.       print("no RFID card inserted")
  38.       s.start(1,200)
  39.       sleep(0.5)
  40.       s.stop(1)
  41.       sleep(1)
  42.       clear()
  43.     end
  44. elseif num == 2 then
  45.   print("scanning")
  46.   r.scan(5)
  47.   z,x = os.pullEvent("rfid_detected")
  48.   print("scanned a RFID card with the code "..x.." on it")
  49.   sleep(3)
  50.   clear()    
  51. elseif num == 3 then
  52.   print("enter a code for your magcard")
  53.   la=tostring(read())
  54.   print("now enter a label")
  55.   oa=tostring(read())
  56.   print("now swipe your magcard on the reader (left)")
  57.   m.setInsertCardLight(true)
  58.   m.beginWrite(la,oa)
  59.   os.pullEvent("mag_write_done")
  60.   print("done!")
  61.   m.setInsertCardLight(false)
  62.   sdb(0)
  63.   s.start(1,400)
  64.   sleep(1)
  65.   s.stop(1)
  66.   clear()
  67. elseif num == 4 then
  68.   print("scanning...")
  69.   za,xa = os.pullEvent("mag_swipe")
  70.   print("scanned a magcard with "..xa.." on it")
  71.   s.start(1,400)
  72.   sleep(0.5)
  73.   s.stop(1)
  74.   sleep(3)
  75.   clear()
  76. elseif num == 5 then clear() break end
  77. end
  78.  
  79. print("bye bye!")
  80. sleep(1)
  81. clear()
Advertisement
Add Comment
Please, Sign In to add comment