-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* changed shield examples * changed shield links * added example text * added getting-started * added getting started * upate shield getting started * add new examples * add sleep and scan examples * update links * changed links to release
- Loading branch information
Showing
14 changed files
with
466 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
Title: "Scanning" | ||
--- | ||
|
||
>This example can be used on the **Pyscan** | ||
You can use the example below to scan RFID / NFC cards presented to the scanner: | ||
```python | ||
from pyscan import Pyscan | ||
from MFRC630 import MFRC630 | ||
import time | ||
import pycom | ||
import _thread | ||
|
||
VALID_CARDS = [[0x43, 0x95, 0xDD, 0xF8], | ||
[0x43, 0x95, 0xDD, 0xF9]] | ||
|
||
py = Pyscan() | ||
nfc = MFRC630(py) | ||
|
||
RGB_BRIGHTNESS = 0x8 | ||
|
||
RGB_RED = (RGB_BRIGHTNESS << 16) | ||
RGB_GREEN = (RGB_BRIGHTNESS << 8) | ||
RGB_BLUE = (RGB_BRIGHTNESS) | ||
|
||
# Make sure heartbeat is disabled before setting RGB LED | ||
pycom.heartbeat(False) | ||
|
||
# Initialise the MFRC630 with some settings | ||
nfc.mfrc630_cmd_init() | ||
|
||
def check_uid(uid, len): | ||
return VALID_CARDS.count(uid[:len]) | ||
|
||
def discovery_loop(nfc, id): | ||
while True: | ||
# Send REQA for ISO14443A card type | ||
atqa = nfc.mfrc630_iso14443a_WUPA_REQA(nfc.MFRC630_ISO14443_CMD_REQA) | ||
if (atqa != 0): | ||
# A card has been detected, read UID | ||
uid = bytearray(10) | ||
uid_len = nfc.mfrc630_iso14443a_select(uid) | ||
if (uid_len > 0): | ||
if (check_uid(list(uid), uid_len)) > 0: | ||
pycom.rgbled(RGB_GREEN) | ||
else: | ||
pycom.rgbled(RGB_RED) | ||
else: | ||
# No card detected | ||
pycom.rgbled(RGB_BLUE) | ||
nfc.mfrc630_cmd_reset() | ||
time.sleep(.5) | ||
nfc.mfrc630_cmd_init() | ||
|
||
# This is the start of our main execution... start the thread | ||
_thread.start_new_thread(discovery_loop, (nfc, 0)) | ||
``` |
Oops, something went wrong.