From b71654f673fa62588eff848c3b69027de6b71fe3 Mon Sep 17 00:00:00 2001 From: Eyuep Sueyruege Date: Tue, 14 Nov 2023 16:13:44 +0100 Subject: [PATCH] Update src/arduino/card_scanner.ino --- src/arduino/card_scanner.ino | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/arduino/card_scanner.ino b/src/arduino/card_scanner.ino index ddbe7a2..b833a24 100644 --- a/src/arduino/card_scanner.ino +++ b/src/arduino/card_scanner.ino @@ -1,29 +1,22 @@ // imports #include #include -#include -#include + // Pin Definition #define SS_PIN 10 #define RST_PIN 9 // Instatiate Motor and RFID Module -Servo motor; + MFRC522 rfid(SS_PIN, RST_PIN); - +byte nuidPICC[4]; // Setup for first time void setup() { // Serial Begin Serial.begin(9600); - // Servo Attach - motor.attach(6); - // Pin Setting - pinMode(2, OUTPUT); - pinMode(3, OUTPUT); - // Init SPI bus SPI.begin(); // Init MFRC522 @@ -32,7 +25,7 @@ void setup() { // iteration void loop() { - // Reset the loop if no new card present on the reader + // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle. if (!rfid.PICC_IsNewCardPresent()){ return; } @@ -40,9 +33,14 @@ void loop() { if (!rfid.PICC_ReadCardSerial()){ return; } + + for (byte i = 0; i < 4; i++) { + nuidPICC[i] = rfid.uid.uidByte[i]; + } + + String id = "ID: "+String(nuidPICC[0])+" : "+String(nuidPICC[1])+" : "+String(nuidPICC[2])+" : "+String(nuidPICC[3]); + Serial.println(id); - // Send UID of token to the serialport - Serial.println(rfid.uid) delay(1000); @@ -52,4 +50,4 @@ void loop() { // Stop encryption on PCD rfid.PCD_StopCrypto1(); -} +} \ No newline at end of file