Here is my code:
/*
This project is using an Keyestudio Arduino Mega R3. I'm using this board basicly for extra digital pins, and extra specs for the two 0.5 Metre NeoPixel Strips + a one 12 Pixel NeoPixel Ring from Adafruit.
Lights: 1 Metre NeoPixel Strip, 12 Pixel NeoPixel Ring, Various attachement mathods (incl. light strip brackets from Adafruit.)
RFID Module: RFID-RC522 + RFID Card & Key Chain RFID Tag
L.C. LCD Display: Adafruit L.C. LCD (16 x 2)
Interface Buttons: Buttons that came in a Rasperry Pi starter project kit. ¯\_(ツ)_/¯
Arduinio: Elegoo Arduino Mega R3
Extra components came with the Mega R3 in another kit.
*/
// Include The Adafruit NeoPixel Library
#include <Adafruit_NeoPixel.h>
// Include The RFID-RC522 Module Library
#include <MFRC522.h>
#include <SPI.h>
// Include The Liquid Crystal LCD Display Library
#include <LiquidCrystal.h>
/*-----------------------------------------------------*/
// NeoPixel Variables
#define NEO_STRIP1_PIN
#define NEO_STRIP1_NUM 60
#define NEO_RING_PIN
#define NEO_RING_NUM 12
// RFID-RC522 Variables
#define RFID_SDA 53
#define RFID_RST 49
#define RFID_SIGNED_IN 0
// Liquid Crystal LCD Variables
#define LCD_RS 9
#define LCD_EN 8
#define LCD_D4 4
#define LCD_D5 5
#define LCD_D6 6
#define LCD_D7 7
/*-----------------------------------------------------*/
// Global Initialization stuff
// Define the pins that the L.C. LCD will use, I'm using the 4 pin method.
LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
// Init of the RC522 with the decleared pins.
MFRC522 mfrc522(RFID_SDA, RFID_RST);
String read_rfid;
String verifyed_rfid="D5 93 AB 75";
/*-----------------------------------------------------*/
// Setup Code, Runs at reset!
void setup() {
/*L.C. LCD Setup*/
// Define the "resolution" of the L.C. LCD (Line Leigith, # Of Lines).
lcd.begin(16, 2);
// Set L.C. LCD to prep to show what is running currently!
lcd.setCursor(0, 0);
lcd.clear();
delay(2000);
lcd.print("Init System ...");
// This is where we put the name of the section that we are initalising!
lcd.setCursor(0, 1);
lcd.print("LCD Drivers");
// Set the pin modes of all L.C. LCD connected pins
pinMode(LCD_RS, OUTPUT);
pinMode(LCD_EN, OUTPUT);
pinMode(LCD_D4, OUTPUT);
pinMode(LCD_D5, OUTPUT);
pinMode(LCD_D6, OUTPUT);
pinMode(LCD_D7, OUTPUT);
delay(1000);
/*RFID-RC522 Setup*/
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Init System");
lcd.setCursor(0, 1);
lcd.print("MFRC522 Drivers");
RFID_SIGNED_IN == 0;
SPI.begin();
Serial.begin(9600);
// Init MFRC522 card
mfrc522.PCD_Init();
delay(1000);
/*NeoPixel Setup*/
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Init System");
lcd.setCursor(0, 1);
lcd.print("NeoPixel Drivers");
delay(1000);
// Print "Finished, Booting"
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Finished Setup");
delay(3000);
// Print ready message
lcd.clear();
delay(1000);
lcd.setCursor(0, 0);
lcd.print("Please identify");
lcd.setCursor(0, 1);
lcd.print("yourself ...");
}
// Loop Code, Runs after "setup" func. Also, this func. loops untill reset!
void loop() {
/*RFID Verify Code*/
// Look for new cards
if (! mfrc522.PICC_IsNewCardPresent())
return;
if (! mfrc522.PICC_ReadCardSerial())
return;
dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
if (RFID_SIGNED_IN == 1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hello, NAME");
// This line will run accepted code
} else if (read_rfid==verifyed_rfid) {
RFID_SIGNED_IN == 1;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hello, NAME");
// This will also run accepted code
} else if (read_rfid!=verifyed_rfid) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Not Accepted,");
lcd.setCursor(0,1);
lcd.print("Try Again");
// this will run non accepted code
}
if (RFID_SIGNED_IN == 1) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Hello, NAME");
// Also runs accepted code so you don't have to scan everytime
}
}
void dump_byte_array(byte *buffer, byte bufferSize) {
read_rfid="";
for (byte 1 == 0; i < bufferSize; i++) {
read_rfid=read_rfid + String(buffer[i], HEX);
}
}
/* Code was written by Reboot_Codes, this might have been edited!
Edited by YOUR_ARDUINO_USERNAME. */
I will post it later in a project, but in the compiler, I get all of these error messages, which shouldn't be here as I copied most of the mfrc522 code from a sketch that worked. And everytime I try debugging I never works! all issues are found here.
Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Users***\Documents\Arduino\Desk Glow With RFID\sketch_may29a\sketch_may29a.ino: In function 'void dump_byte_array(byte, byte)':
sketch_may29a:171:15: error: expected unqualified-id before numeric constant
for (byte 1 == 0; i < bufferSize; i++) {
^
sketch_may29a:171:15: error: expected ';' before numeric constant
sketch_may29a:171:23: error: 'i' was not declared in this scope
for (byte 1 == 0; i < bufferSize; i++) {
^
sketch_may29a:171:37: error: expected ')' before ';' token
for (byte 1 == 0; i < bufferSize; i++) {
^
sketch_may29a:171:39: error: 'i' was not declared in this scope
for (byte 1 == 0; i < bufferSize; i++) {
^
exit status 1
expected unqualified-id before numeric constant
Yes, I know that I should debug it myself, but I kinda need help with this as I'm re-learing all of my Arduino code skills. This is also obviously not the final code, but this has the most complex stuff that I really need help with.
But help would be greatly appreciated.