update examples
This commit is contained in:
parent
b55dcd29d0
commit
08fa1eabaa
2 changed files with 20 additions and 10 deletions
|
@ -8,13 +8,18 @@ After initialization, try waving various 13.56MHz RFID cards over it!
|
||||||
import board
|
import board
|
||||||
import busio
|
import busio
|
||||||
from digitalio import DigitalInOut
|
from digitalio import DigitalInOut
|
||||||
import adafruit_pn532
|
#
|
||||||
|
# NOTE: pick the import that matches the interface being used
|
||||||
|
#
|
||||||
|
from adafruit_pn532.i2c import PN532_I2C
|
||||||
|
#from adafruit_pn532.spi import PN532_SPI
|
||||||
|
#from adafruit_pn532.uart import PN532_UART
|
||||||
|
|
||||||
# I2C connection:
|
# I2C connection:
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
i2c = busio.I2C(board.SCL, board.SDA)
|
||||||
|
|
||||||
# Non-hardware
|
# Non-hardware
|
||||||
#pn532 = adafruit_pn532.PN532_I2C(i2c, debug=False)
|
#pn532 = PN532_I2C(i2c, debug=False)
|
||||||
|
|
||||||
# With I2C, we recommend connecting RSTPD_N (reset) to a digital pin for manual
|
# With I2C, we recommend connecting RSTPD_N (reset) to a digital pin for manual
|
||||||
# harware reset
|
# harware reset
|
||||||
|
@ -22,16 +27,16 @@ reset_pin = DigitalInOut(board.D6)
|
||||||
# On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
|
# On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
|
||||||
# wakeup! this means we don't need to do the I2C clock-stretch thing
|
# wakeup! this means we don't need to do the I2C clock-stretch thing
|
||||||
req_pin = DigitalInOut(board.D12)
|
req_pin = DigitalInOut(board.D12)
|
||||||
pn532 = adafruit_pn532.PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
|
pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
|
||||||
|
|
||||||
# SPI connection:
|
# SPI connection:
|
||||||
#spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
|
#spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
|
||||||
#cs_pin = DigitalInOut(board.D5)
|
#cs_pin = DigitalInOut(board.D5)
|
||||||
#pn532 = adafruit_pn532.PN532_SPI(spi, cs_pin, debug=False)
|
#pn532 = PN532_SPI(spi, cs_pin, debug=False)
|
||||||
|
|
||||||
# UART connection
|
# UART connection
|
||||||
#uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
|
#uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
|
||||||
#pn532 = adafruit_pn532.PN532_UART(uart, debug=False)
|
#pn532 = PN532_UART(uart, debug=False)
|
||||||
|
|
||||||
ic, ver, rev, support = pn532.get_firmware_version()
|
ic, ver, rev, support = pn532.get_firmware_version()
|
||||||
print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
|
print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
|
||||||
|
|
|
@ -28,13 +28,18 @@ type RFID tag
|
||||||
import board
|
import board
|
||||||
import busio
|
import busio
|
||||||
from digitalio import DigitalInOut
|
from digitalio import DigitalInOut
|
||||||
import adafruit_pn532
|
#
|
||||||
|
# NOTE: pick the import that matches the interface being used
|
||||||
|
#
|
||||||
|
#from adafruit_pn532.i2c import PN532_I2C
|
||||||
|
from adafruit_pn532.spi import PN532_SPI
|
||||||
|
#from adafruit_pn532.uart import PN532_UART
|
||||||
|
|
||||||
# I2C connection:
|
# I2C connection:
|
||||||
#i2c = busio.I2C(board.SCL, board.SDA)
|
#i2c = busio.I2C(board.SCL, board.SDA)
|
||||||
|
|
||||||
# Non-hardware reset/request with I2C
|
# Non-hardware reset/request with I2C
|
||||||
#pn532 = adafruit_pn532.PN532_I2C(i2c, debug=False)
|
#pn532 = PN532_I2C(i2c, debug=False)
|
||||||
|
|
||||||
# With I2C, we recommend connecting RSTPD_N (reset) to a digital pin for manual
|
# With I2C, we recommend connecting RSTPD_N (reset) to a digital pin for manual
|
||||||
# harware reset
|
# harware reset
|
||||||
|
@ -42,16 +47,16 @@ import adafruit_pn532
|
||||||
# On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
|
# On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
|
||||||
# wakeup! this means we don't need to do the I2C clock-stretch thing
|
# wakeup! this means we don't need to do the I2C clock-stretch thing
|
||||||
#req_pin = DigitalInOut(board.D12)
|
#req_pin = DigitalInOut(board.D12)
|
||||||
#pn532 = adafruit_pn532.PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
|
#pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
|
||||||
|
|
||||||
# SPI connection:
|
# SPI connection:
|
||||||
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
|
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
|
||||||
cs_pin = DigitalInOut(board.D5)
|
cs_pin = DigitalInOut(board.D5)
|
||||||
pn532 = adafruit_pn532.PN532_SPI(spi, cs_pin, debug=False)
|
pn532 = PN532_SPI(spi, cs_pin, debug=False)
|
||||||
|
|
||||||
# UART connection
|
# UART connection
|
||||||
#uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
|
#uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
|
||||||
#pn532 = adafruit_pn532.PN532_UART(uart, debug=False)
|
#pn532 = PN532_UART(uart, debug=False)
|
||||||
|
|
||||||
ic, ver, rev, support = pn532.get_firmware_version()
|
ic, ver, rev, support = pn532.get_firmware_version()
|
||||||
print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
|
print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue