RFID 125kHz scaner

I have a program that is to send a signal of 10 saved RFID codes to the transmitter.
The appropriate code will open the door.
The program only reads the first code.
How to make him read all the codes cyclically in turn?
No errors in the sketch.
Arduino Nano

#include <Arduino.h>
// Define the Arduino PIN
#define NTAGS 10
#define TAGLEN 10
#define coil_pin 2
char data[NTAGS][TAGLEN] = {

{'0','6','0','0','C','A','F','E','4','2',}, /* ID=1 /
{'0','B','5','7','8','1','4','6','0','1',}, /
ID=2 /
{'0','4','0','0','7','1','1','3','3','5',}, /
ID=3 /
{'0','0','1','3','5','5','3','9','0','4',}, /
ID=4 /
{'5','6','5','A','1','1','4','0','B','E',}, /
ID=5 /
{'3','6','5','A','3','9','8','1','4','9',}, /
ID=6 /
{'0','6','0','0','C','A','F','E','4','2',}, /
ID=7 /
{'0','6','0','0','C','A','F','E','4','2',}, /
ID=8 /
{'0','6','0','0','C','A','F','E','4','2',}, /
ID=9 /
{'0','6','0','0','C','A','F','E','4','2',}, /
ID=10 */
};

int spoofed_card[64];

void build_content();
void spoofnow();
int HexToDec(char hexa);
void send_manchester(int clock_half, int signal);

void setup()
{
Serial.begin(9600);
pinMode(coil_pin, OUTPUT);
digitalWrite(coil_pin, LOW);
build_content();
}

void loop()
{
delay(500);
Serial.println("Ready for spoofing");

for (int h = 0; h < 50; h++)
spoofnow();

Serial.println("Spoof done");
}

void build_content()
{
// Iterator for the ID wanted
int data_iterator = 0;
// Hex value of the ID
int raw_data;

// Initialize the first 9 bits to 1
for (int i = 0; i < 9; i++)
{
spoofed_card[i] = 1;
}

// Set the 5th bit as parity (calculated at the end)

// This loop writes each hex digit in bits
for (int a = 0; a < 10; a++)
{
raw_data = HexToDec(data[data_iterator][a]);
spoofed_card[(a * 5) + 9] = bitRead(raw_data, 3);
spoofed_card[(a * 5) + 10] = bitRead(raw_data, 2);
spoofed_card[(a * 5) + 11] = bitRead(raw_data, 1);
spoofed_card[(a * 5) + 12] = bitRead(raw_data, 0);
}

// CRC ROW
for (int r = 0; r < 10; r++)
{
int bit_set = 0;
// Calculate the number of 1s per row
for (int i = 0; i < 4; i++)
{
if (spoofed_card[(r * 5) + i + 9])
{
bit_set++;
}
}

// If the number of 1s is even, set parity to 1, else 0
spoofed_card[(5 * r) + 4 + 9] = (bit_set % 2 != 0) ? 1 : 0;

}

// CRC COLUMN
for (int c = 0; c < 4; c++)
{
int bit_set = 0;
// Calculate the number of 1s per column
for (int i = 0; i < 10; i++)
{
if (spoofed_card[c + (i * 5) + 9])
{
bit_set++;
}
}

// If the number of 1s is even, set parity to 1, else 0
spoofed_card[50 + 9 + c] = (bit_set % 2 != 0) ? 1 : 0;

}

// Last bit = stop bit = 0
spoofed_card[63] = 0;
}

// Function that converts Hexadecimal to Decimal
int HexToDec(char hexa)
{
if (hexa >= '0' && hexa <= '9')
return hexa - '0';
if (hexa >= 'A' && hexa <= 'F')
return hexa - 'A' + 10;
if (hexa >= 'a' && hexa <= 'f')
return hexa - 'a' + 10;
// Handle invalid characters here, e.g., return an error code.
// You can also choose to ignore or skip invalid characters.
return -1; // Return an error code for invalid characters
}

void spoofnow()
{
for (int i = 0; i < 64; i++)
{
send_manchester(0, spoofed_card[i]);
delayMicroseconds(256);
send_manchester(1, spoofed_card[i]);
delayMicroseconds(256);
}
}

void send_manchester(int clock_half, int signal)
{
// XOR the clock and the signal
int man_encoded = clock_half ^ signal;

if (man_encoded)
{
digitalWrite(coil_pin, LOW);
}
else
{
digitalWrite(coil_pin, HIGH);
}
}

I moved your topic to an appropriate forum category @perseusz.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.