I am trying to use the RFIDuino library and affiliated hardware (I know it's very outdated, but I am trying to avoid purchasing any additional hardware) and the script will not work on a Arduino Uno R4 Wifi when it will work on a Arduino Uno R3. The pinouts seem to be the same.
#include <RFIDuino.h> //include the RFIDuino Library
#define SERIAL_PORT Serial //Serial port definition for Geekduino, Arduino Uno, and most Arduino Boards
//Program to open door for Room 131
boolean tagCheck = false; //true when a tag has been read, false otherwise
RFIDuino myRFIDuino(1.1); //initialize an RFIDuino object for hardware version 1.1
int myTags[1][5] = { //Declares Tag Value of Valid Tags, tags are ordered same as in spreadsheet
{85,0,46,147,158}
}; //Begin BackEnd
#define RELAY 9 //the relay PinOut
void setup() { //Setup Code
SERIAL_PORT.begin(19200); //Declare Baud rate for Arduino at 19200
Serial.println("Begin");
pinMode(RELAY, OUTPUT); //The relay must be manuualy initalized as an output
beep(2, 2); //Beep the Arduino twice
}
void beep(int bp, int gb) { //Makes it beep
int tkn = 0;
if(gb == 1){
myRFIDuino.successSound();
}
else if(gb == 0){
myRFIDuino.errorSound();
}
else{
for (tkn; tkn < bp; tkn++) { //beeps inputed (bp) amount of time
digitalWrite(myRFIDuino.buzzer, HIGH); delay(100); digitalWrite(myRFIDuino.buzzer, LOW); delay(100);
}
}
}
void flash(int fls){ //Makes it Flash
int tkn = 0;
for (tkn; tkn < fls; tkn++) { //beeps inputed (bp) amount of time
digitalWrite(myRFIDuino.led2, HIGH); delay(50); digitalWrite(myRFIDuino.led2, LOW); delay(50);
}
}
byte tagData[5]; //Holds the ID numbers from the tag
int i = 0; //Counting variable for counter function
void loop() { //Main Loop Code
tagCheck = myRFIDuino.decodeTag(tagData); //run the decodetag to check for the tag. If a tag is read then the function will return 'true' and load the data into 'tagData'
if (tagCheck==true) { //if a 'true' is returned from the decodetag function, a tag was succesffuly scanned
check(); //Transfer to Scan Function
tagCheck = false;
delay(500);
}
}
boolean goodScan = false;
void check(){ //Compares tag vs valid tags
int i = 0;
while(i < sizeof(myTags)/10){ //checks all tags that are in myTags array
//sizeof() reads array byte length, so a 5 long array of numbers, that are less than 256, will be two bytes times 5 numbers,
//thus each array is 10 in length, so sizeof(myTags) = 30. Dividing by 3 fixes this issue.
//printTag(); //troubleshooting prints
for (int n = 0; n < 5; n++) { //Loop to check each digit in both the scanned and valid tag values
if(tagData[n] == myTags[i][n]){ //Checks position n of each array
goodScan = true; //Returns true if matched
}
else{
goodScan = false; //Returns fasle if not
break; //Breaks loop, as value is not the same
}
}
if(goodScan == true){
break; //breaks value if loop ends with a valid number
}
i++;
}
if(goodScan == true){
beep(1, 1);
digitalWrite(RELAY,HIGH); //turn the relay/solenoid off
delay(1500); //Wait 1.5 seconds before closing relay/solenoid
digitalWrite(RELAY,LOW); //turn the relay/solenoid off
goodScan = false;
}else{
beep(1, 0);
goodScan = false;
}
}
Whenever plugged into power, the system should been twice, sometimes 4 times, to signify that the system is ready. However, when attached to the R4 Wifi, it does nothing. Also, whenever incorporating the RFIDuino system into other scripts, as soon as '''RFIDuino myRFIDuino(1.1);''' is declared, the program proceeds to break.