I was using examples and copying them into one program to work and it was sating that some functions in the Librarys wren't declared in the scope. I went back to the example and It worked perfectly.
Here is the code
const int chipSelectPin = 10;
const int NRSTPD = 5;
int StatoSwitch = 0;
int i = 0;
int val = LOW;
int pre_val = LOW;
int state = 0;
int RFID_val;
#define MAX_LEN 16
void setup(){
Serial.begin(9600);
SPI.begin();
pinMode(chipSelectPin,OUTPUT); // Set digital pin 10 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(chipSelectPin, LOW); // Activate the RFID reader
pinMode(NRSTPD,OUTPUT); // Set digital pin 10 , Not Reset and Power-down
digitalWrite(NRSTPD, HIGH);
pinMode(ALARMSOUNDER, OUTPUT);
myRFID.AddicoreRFID_Init();
}
void loop()
{
myRFID.AddicoreRFID_Init();
//Find tags, return tag type
status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str);
if (status == MI_OK)
{
Serial.println("RFID tag detected");
Serial.print(str[0],BIN);
Serial.print(" , ");
Serial.print(str[1],BIN);
Serial.println(" ");
}
//Anti-collision, return tag serial number 4 bytes
status = myRFID.AddicoreRFID_Anticoll(str);
if (status == MI_OK)
{
checksum1 = str[0] ^ str[1] ^ str[2] ^ str[3];
Serial.println("The tag's number is : ");
//Serial.print(2);
Serial.print(str[0]);
Serial.print(" , ");
Serial.print(str[1],BIN);
Serial.print(" , ");
Serial.print(str[2],BIN);
Serial.print(" , ");
Serial.print(str[3],BIN);
Serial.print(" , ");
Serial.print(str[4],BIN);
Serial.print(" , ");
Serial.println(checksum1,BIN);
if(str[0] == 156) //You can change this to the first byte of your tag by finding the card's ID through the Serial Monitor
{
RFID_val = HIGH;
}
StatoSwitch = digitalRead(pinSwitch);
if (StatoSwitch == LOW && RFID_val = LOW) {
Serial.println("HIGH!");
for(i = 0; i < 255; i = i + 2)
{
analogWrite(ALARMSOUNDER, i);
delay(10);
}
for(i = 255; i > 1; i = i - 2)
{
analogWrite(ALARMSOUNDER, i);
delay(5);
}
for(i = 1; i <= 10; i++)
{
analogWrite(ALARMSOUNDER, 200);
delay(100);
analogWrite(ALARMSOUNDER, 25);
delay(100);
}
}
else if (StatoSwitch == HIGH && RFID_val == HIGH)
{
analogWrite(ALARMSOUNDER, 0);
delay(5000);
RFID_val = LOW;
}
pre_val = val;
myRFID.AddicoreRFID_Halt();
}
Basically I need help on If it's my problem or the compiler error.