Created
June 17, 2016 17:39
-
-
Save ceremcem/0eba31448adb642470206e04667b65a9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{sleep} = require \aea | |
rfid = void | |
stm = yes | |
esp12 = no | |
setup = -> | |
if stm and not esp12 | |
console.log "----- this is STM32-DISCOVERY" | |
spi-pins = {sck:A5, mosi:A7, miso:A6} | |
cs = A4 | |
else | |
console.log "----- this is ESP-WIFI" | |
spi-pins = {sck:D14, mosi:D13, miso:D12, baud: 400_000Hz} | |
cs = D15 | |
SPI1.setup(spi-pins); | |
rfid := require("MFRC522").connect(SPI1, cs); | |
rfid-test = -> | |
console.log "trying to find card" | |
rfid.findCards( (card) -> | |
console.log "Found #{card}") | |
run = yes | |
on-init = -> | |
setup! | |
<- :lo(op) -> | |
if run | |
rfid-test! | |
<- sleep 1000ms | |
lo(op) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment