Hello everyone,
I'm doing a University project and designing a small parking with a RFID_RC522 for access control and a Micro Servo that controls a barrier (if that's the word you use in English for that). I verified and re-verified my code and connections and can't get the hang of it. The LED together with the buzzer are pinned to a breadboard and since I'm doing testing RED LED, GREEN LED and BUZZER share the same GROUND from POWER "section" of an Arduino UNO.
When the RFID TAG UID is not stored in the system, we have the RED LED lightning and the buzzer making a "reject" sound.
When the RFID TAG UID is in the system, the GREEN LED SHOULD light up, a short buzzer beep and the servo does his stuff.
The thing is, the green LED never turns on - I verified it and it's in working condition (even if I replace the RED LED with GREEN it never lights), some fractions of code:
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
#define SS_PIN 10
#define RST_PIN 9
#define LED_G 5 //define green LED pin
#define LED_R 4 //define red LED
#define BUZZER 2 //buzzer pin
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
Servo myServo; //define servo name
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
myServo.attach(3); //servo pin
myServo.write(0); //servo start position
pinMode(LED_G, OUTPUT);
pinMode(LED_R, OUTPUT);
pinMode(BUZZER, OUTPUT);
noTone(BUZZER);
Serial.println("Put your card to the reader...");
Serial.println();
...
if (content.substring(1) == "XX XX XX XX")
{
Serial.println("Authorized access");
Serial.println();
delay(500);
digitalWrite(LED_G, HIGH);
tone(BUZZER, 500);
delay(300);
noTone(BUZZER);
myServo.write(180);
delay(5000);
myServo.write(0);
digitalWrite(LED_G, LOW);
}
else {
Serial.println(" Access denied");
digitalWrite(LED_R, HIGH);
tone(BUZZER, 300);
delay(1000);
digitalWrite(LED_R, LOW);
noTone(BUZZER);
}
}
Else, the system works flawlessly - I'm guessing there is a problem with the delay conflict of the motor and LED or other problem with my code that I'm not aware of. Can someone give me some hints?
Thank you,
InvalidIP