Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- s = peripheral.wrap("back") --speaker
- w = peripheral.wrap("top") --rfid writer
- r = peripheral.wrap("right")--rfid reader
- m = peripheral.wrap("left") --magcard
- function sdb(db)
- s.setAttenuation(db)
- end
- while true do
- 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")
- num=tonumber(read())
- if num == 1 then
- if w.isPresent() == true then
- print("enter a code for your RFID card")
- c=read()
- print("now enter a label")
- l=read()
- print("encoding...")
- w.encode(tostring(c),tostring(l))
- sdb(10)
- s.start(2,200)
- os.pullEvent("rfid_written")
- print("done!\nplease take out your card")
- s.stop(2)
- sdb(0)
- s.start(1,400)
- sleep(1)
- s.stop(1)
- clear()
- else
- print("no RFID card inserted")
- s.start(1,200)
- sleep(0.5)
- s.stop(1)
- sleep(1)
- clear()
- end
- elseif num == 2 then
- print("scanning")
- r.scan(5)
- z,x = os.pullEvent("rfid_detected")
- print("scanned a RFID card with the code "..x.." on it")
- sleep(3)
- clear()
- elseif num == 3 then
- print("enter a code for your magcard")
- la=tostring(read())
- print("now enter a label")
- oa=tostring(read())
- print("now swipe your magcard on the reader (left)")
- m.setInsertCardLight(true)
- m.beginWrite(la,oa)
- os.pullEvent("mag_write_done")
- print("done!")
- m.setInsertCardLight(false)
- sdb(0)
- s.start(1,400)
- sleep(1)
- s.stop(1)
- clear()
- elseif num == 4 then
- print("scanning...")
- za,xa = os.pullEvent("mag_swipe")
- print("scanned a magcard with "..xa.." on it")
- s.start(1,400)
- sleep(0.5)
- s.stop(1)
- sleep(3)
- clear()
- elseif num == 5 then clear() break end
- end
- print("bye bye!")
- sleep(1)
- clear()
Advertisement
Add Comment
Please, Sign In to add comment