Hello
Sorry, but I don't know very good speak English. Can you help me with this program?
This program read card ID and open door if autentification is OK. I can add only 60 String object for correct detect ID. If add String ok_61=""; and more, arduino no detect any ID. I need detect 100 ID tag for my project. Please help me. Thank you for your respons.
#######################START PROGRAM##########################
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9 // Configurable, see typical pin layout above
#define SS_PIN 10 // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
String read_rfid;
String ok_1="000000";
String ok_2="000000";
String ok_3="000000";
String ok_4="000000";
String ok_5="000000";
String ok_6="000000";
String ok_7="000000";
String ok_8="000000";
String ok_9="000000";
String ok_10="000000";
String ok_11="000000";
String ok_12="000000";
String ok_13="000000";
String ok_14="00000";
String ok_15="000000";
String ok_16="000000";
String ok_17="000000";
String ok_18="000000";
String ok_19="000000";
String ok_20="000000";
String ok_21="000000";
String ok_22="000000";
String ok_23="000000";
String ok_24="000000";
String ok_25="000000";
String ok_26="000000";
String ok_27="000000";
String ok_28="0000000";
String ok_29="000000";
String ok_30="000000";
String ok_31="000000";
String ok_32="000000";
String ok_33="000000";
String ok_34="000000";
String ok_35="000000";
String ok_36="000000";
String ok_37="000000";
String ok_38="000000";
String ok_39="000000";
String ok_40="000000";
String ok_41="000000";
String ok_42="000000";
String ok_43="000000";
String ok_44="000000";
String ok_45="000000";
String ok_46="000000";
String ok_47="000000";
String ok_48="000000";
String ok_49="000000";
String ok_50="000000";
String ok_51="000000";
String ok_52="000000";
String ok_53="000000";
String ok_54="000000";
String ok_55="000000";
String ok_56="000000";
String ok_57="000000";
String ok_58="000000";
String ok_59="000000";
String ok_60="000000";
String ok_61="000000";
int lock=7; //Which pin the lock will be on if using a relay or solenoid or similar
int buzzerPin=2; //Define buzzerPin
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
//Choose which lock below:
pinMode(lock, OUTPUT);
pinMode(buzzerPin, OUTPUT);
digitalWrite(lock, HIGH);
}
/*
* Helper routine to dump a byte array as hex values to Serial.
*/
void dump_byte_array(byte *buffer, byte bufferSize) {
read_rfid="";
for (byte i = 0; i < bufferSize; i++) {
read_rfid=read_rfid + String(buffer[i], HEX);
}
}
void beep(unsigned char delayms) { //creating function
analogWrite(buzzerPin, 200); //Setting pin to high
delay(delayms); //Delaying
analogWrite(buzzerPin ,0); //Setting pin to LOW
delay(delayms); //Delaying
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
return;
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
return;
dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
Serial.println(read_rfid);
int x = 1;
if (read_rfid==ok_1 || read_rfid==ok_2 || read_rfid==ok_3 || read_rfid==ok_4 || read_rfid==ok_5 || read_rfid==ok_6 || read_rfid==ok_7 || read_rfid==ok_8 || read_rfid==ok_9 || read_rfid==ok_10 || read_rfid==ok_11 || read_rfid==ok_12 || read_rfid==ok_13 || read_rfid==ok_14 || read_rfid==ok_15 || read_rfid==ok_16 || read_rfid==ok_17 || read_rfid==ok_18 || read_rfid==ok_19 || read_rfid==ok_20 || read_rfid==ok_21 || read_rfid==ok_22 || read_rfid==ok_23 || read_rfid==ok_24 || read_rfid==ok_25 || read_rfid==ok_26 || read_rfid==ok_27 || read_rfid==ok_28 || read_rfid==ok_29 || read_rfid==ok_30 || read_rfid==ok_31 || read_rfid==ok_32 || read_rfid==ok_33 || read_rfid==ok_34 || read_rfid==ok_35 || read_rfid==ok_36 || read_rfid==ok_37 || read_rfid==ok_38 || read_rfid==ok_39 || read_rfid==ok_40 || read_rfid==ok_41 || read_rfid==ok_42 || read_rfid==ok_43 || read_rfid==ok_44 || read_rfid==ok_45 || read_rfid==ok_46 || read_rfid==ok_47 || read_rfid==ok_48 || read_rfid==ok_49 || read_rfid==ok_50 || read_rfid==ok_51 || read_rfid==ok_52 || read_rfid==ok_53 || read_rfid==ok_54 || read_rfid==ok_55 || read_rfid==ok_56 || read_rfid==ok_57 || read_rfid==ok_58 || read_rfid==ok_59 || read_rfid==ok_60 || read_rfid==ok_61) {
//ok, open the door.
Serial.println("Authetificate OK");
digitalWrite(lock, LOW);
for (int i=0; i <= 10; i++){
beep(50);
delay(100);
}
digitalWrite(lock, HIGH);
}
######################END PROGRAM#####################