from machine import Pin, SPI
import time
spi = SPI(0, baudrate=1000000, polarity=0, phase=0, sck=Pin(2), mosi=Pin(3), miso=Pin(4))
cs = Pin(5, Pin.OUT)
cs.value(1)
print("--- RFID SPI Test Bermula ---")
while True:
try:
cs.value(0)
spi.write(b'\x99')
respon = spi.read(1)
cs.value(1)
print("Data dihantar: 0x99 | Respon diterima:", respon)
except Exception as e:
print("Ralat:", e)
time.sleep(1)Loading
mfrc522
mfrc522