from machine import Pin from mfrc522 import MFRC522 import utime reader = MFRC522(spi_id=0,sck=2,miso=4,mosi=3,cs=1,rst=0) red = Pin(13, Pin.OUT) green = Pin(12, Pin.OUT) blue = Pin(11, Pin.OUT) print("Bring RFID TAG Closer...") print("") while True: reader.init() (stat, tag_type) = reader.request(reader.REQIDL) if stat == reader.OK: (stat, uid) = reader.SelectTagSN() if stat == reader.OK: card = int.from_bytes(bytes(uid),"little",False) if card == 612121286: print("Card ID: "+ str(card)+" PASS: Green Light Activated") red.value(0) green.value(1) blue.value(0) elif card == 1002696326: print("Card ID: "+ str(card)+" PASS: Blue Light Activated") red.value(0) green.value(0) blue.value(1) else: print("Card ID: "+ str(card)+" UNKNOWN CARD! Red Light Activated") red.value(1) green.value(0) blue.value(0)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter