RC522 RFID Reader Module with Raspberry Pi Pico
Wed Apr 13 2022 14:13:06 GMT+0000 (Coordinated Universal Time)
Saved by
@ehraz786
#python
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)
content_copyCOPY
RFID RC522 RGB LED Control
https://microcontrollerslab.com/raspberry-pi-pico-rfid-rc522-micropython/
Comments