Commit local files
commit
b89e708756
@ -0,0 +1 @@
|
||||
.pio/
|
@ -0,0 +1,18 @@
|
||||
PROJECT_DIR = $(CURDIR)
|
||||
PLATFORMIO_BIN = /bin/pio
|
||||
|
||||
all: build upload
|
||||
|
||||
build:
|
||||
$(PLATFORMIO_BIN) run -d $(PROJECT_DIR)
|
||||
|
||||
upload:
|
||||
$(PLATFORMIO_BIN) run -d $(PROJECT_DIR) -t upload
|
||||
|
||||
clean:
|
||||
$(PLATFORMIO_BIN) run -d $(PROJECT_DIR) -t clean
|
||||
|
||||
monitor:
|
||||
$(PLATFORMIO_BIN) device monitor
|
||||
|
||||
.PHONY: all build upload clean monitor
|
@ -0,0 +1,10 @@
|
||||
[env:uno]
|
||||
platform = atmelavr
|
||||
board = uno
|
||||
framework = arduino
|
||||
upload_port = /dev/ttyUSB0
|
||||
monitor_speed = 9600
|
||||
|
||||
lib_deps =
|
||||
SPI
|
||||
miguelbalboa/MFRC522@^1.4.10
|
@ -0,0 +1,35 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define SS_PIN 10
|
||||
#define RST_PIN 5
|
||||
#define LED_PIN_Y 3
|
||||
#define LED_PIN_N 2
|
||||
const byte uid[4] = {0xF9, 0x7E, 0x9D, 0x2B};
|
||||
|
||||
MFRC522 rfid(SS_PIN, RST_PIN);
|
||||
|
||||
void setup() {
|
||||
SPI.begin();
|
||||
rfid.PCD_Init();
|
||||
pinMode(LED_PIN_Y, OUTPUT);
|
||||
pinMode(LED_PIN_N, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (rfid.PICC_IsNewCardPresent()) {
|
||||
if (rfid.PICC_ReadCardSerial()) {
|
||||
for (int i = 0; i < rfid.uid.size; i++) {
|
||||
if (rfid.uid.uidByte[i] == uid[i]) {
|
||||
digitalWrite(LED_PIN_Y, HIGH);
|
||||
delay(500);
|
||||
digitalWrite(LED_PIN_Y, LOW);
|
||||
} else {
|
||||
digitalWrite(LED_PIN_N, HIGH);
|
||||
delay(500);
|
||||
digitalWrite(LED_PIN_N, LOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue