RFID-RC522 linkage

Hi

I wanna link a arduino to another arduino.

Here's my plan.

If RFID read valid card then transport the signal to another arduino.

then the second arduino turn the LED lights.

and my code is

**Num.1 Arduino

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN 9
#define SS_PIN 10
MFRC522 mfrc(SS_PIN, RST_PIN);
char c;

void setup()
{
Serial.begin(9600);
SPI.begin();

mfrc.PCD_Init();
}

void loop()
{
if(!mfrc.PICC_IsNewCardPresent() || !mfrc.PICC_ReadCardSerial())
{
delay(500);
return;
}

if(mfrc.uid.uidByte[0] == 123 && mfrc.uid.uidByte[1] == 203 && mfrc.uid.uidByte[2] == 7 && mfrc.uid.uidByte[3] == 34)
{
Serial.write('a');
delay(1000);
}
}

**Num2 Arduino Code

void setup()
{
Serial.begin(9600);
pinMode(LED, OUTPUT);
}

void loop()
{
if(Serial.available())
{
char data = (char)Serial.read();
}

if(data == 'a')
{
digitalWrite(LED, HIGH);
Serial.println("Valid Card detected");
}
}

I used that code but it didn't work!

what is problem? plz lemme know. 8ㅅ8

The Serial port is used to download code to an Arduino as well as for serial communication (prints) using the IDE serial monitor.

you typically can't use those pins, 1&2 for other purposes while the USB is connected. you need a power source for the Arduinos without a USB connection.

an Arduino mega has 4 serial interfaces. the Serial1 could be used on your 2 arduinos for communication between them

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