打了一大堆,然後瀏覽器掛掉,又要重打了,真的是GG easy Noobs。所以直接進入安裝環節,順便罵一下Safari真的是不適合拿來打文章?
Noob
的大神來幫助你調整輸出PN532訊號為SPI
SEL0 = OFF
SEL1 = ON
照著adafruit的流程走一遍
首先先安裝python的套件
sudo pip3 install adafruit-circuitpython-pn532
這樣就有一個名為adafruit-circuitpython-pn532
的套件了
接著打程式
import board
import busio
from digitalio import DigitalInOut
from adafruit_pn532.spi import PN532_SPI
# SPI connection:
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs_pin = DigitalInOut(board.D5)
pn532 = PN532_SPI(spi, cs_pin, debug=False)
ic, ver, rev, support = pn532.get_firmware_version()
print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
# Configure PN532 to communicate with MiFare cards
pn532.SAM_configuration()
print('Waiting for RFID/NFC card...')
while True:
# Check if a card is available to read
uid = pn532.read_passive_target(timeout=0.5)
print('.', end="")
# Try again if no card is available.
if uid is None:
continue
print('Found card with UID:', [hex(i) for i in uid])
這樣就可以讀出NFC卡裡面的東西囉,若要做一些關於門鎖的東西,就確認讀入的UID是否在白名單內,就可以囉,高級一點可以用資料庫,不然單純字串比對也是可以的啦