Hi, im a bit stuck,
Ive hooked up an Arduino so that an RFID reader takes in a scanned tag number and sends it to the serial port of the computer(this worked fine), however im now changing it so that the device scans the number then sends it over an RF link to a second Arduino to make the device wireless.
Ive got two problems, the first is that the RFID reader runs at 9600 bps whereas the RF modules run at 2400 bps, can this be fixed?
Also i want the RF to constantly send values 10 - 99 so that there is a constant flow being picked up by the receiver to avoid giberish(which is done if the If statement and For loop are removed), so when a single byte from the RFID is sent then it can be picked out and recognized as the tag number, is there a way to do this so that the loop is only interupted when a tag is scanned? Im aware that the current code does not do that, instead it stops each time and waits for a scan before moving on.
I apologise if there is anything here that is simple to fix or just plain stupid, im relatively new to Arduinos and RF connectivity.
Ive included the code for the transmitting RF module. thanks!
#include <SoftwareSerial.h>
#define rxPin 4
#define txPin 5
#define RFIDrx 2
#define RFIDtx 3
#define ledPin 9
byte val = 10;
SoftwareSerial rfSerial = SoftwareSerial(rxPin, txPin);
SoftwareSerial rfidSerial = SoftwareSerial(RFIDrx, RFIDtx);
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode(RFIDrx, INPUT);
pinMode(RFIDtx, OUTPUT);
rfSerial.begin(2400);
rfidSerial.begin(9600);
Serial.begin(2400);
digitalWrite(ledPin,HIGH);
delay(1000);
digitalWrite(ledPin,LOW);
}
void loop() {
if(val >= 100)
{
val = 10;
}
if(rfidSerial.read() != NULL){
for (int i = 0; i <= 13; i++){ //13 bytes get inputted from the tag
rfSerial.print(rfidSerial.read(), BYTE);
Serial.println(rfidSerial.read(), BYTE);
delay(10);
}
}
Serial.println(val, DEC);
rfSerial.println(val, BYTE);
val++;
delay(10);
}