Hi,
I need to build an Arduino prototype that uses Parallax RFID reader and a Sharp IR proximity sensor.
If I take any of the sample codes from here: Arduino Playground - PRFID
I can read perfectly my tags.
But as soon as I plug a Sharp IR proximity sensor on Arduino UNO, whatever pin (digital, analog), with or without declaring its pin in the Arduino file, the Arduino file doesn't read the tags any more.
I have tried to use Arduino hardware Serial, SoftwareSerial, ReceiveOnlySoftwareSerial and I get the same result.
The RFID reader works fine on its own.
The proximity sensor works fine on its own.
But when I combine both, the proximity sensor works but not the RFID reader anymore.
Any idea why it’s behaving like this?
Thanks in advance.
Code example I’m using:
#include <SoftwareSerial.h>
#define enablePin 7
#define rxPin 8
#define txPin 9
int i=20;
#define BUFSIZE 11
#define RFID_START 0x0A // RFID Reader Start and Stop bytes
#define RFID_STOP 0x0D
SoftwareSerial rfidSerial = SoftwareSerial(rxPin, txPin);
void setup() {
pinMode(enablePin, OUTPUT);
pinMode(rxPin, INPUT);
digitalWrite(enablePin, HIGH); // disable RFID Reader
Serial.begin(9600);
while (!Serial);
Serial.println("\n\nParallax RFID Card Reader");
rfidSerial.begin(2400);
Serial.flush(); // wait for all bytes to be transmitted to the Serial Monitor
}
void loop() {
digitalWrite(enablePin, LOW);
char rfidData[BUFSIZE];
char offset = 0;
rfidData[0] = 0;
if(rfidSerial.available()>0){
rfidData[offset]=rfidSerial.read();
if (rfidData[offset]==RFID_START){
while (offset<BUFSIZE){
if (rfidSerial.available()>0){
rfidData[offset]=rfidSerial.read();
if (rfidData[offset]==RFID_STOP){
rfidData[offset]=0;
break;}
else{ offset++;}
}
}
offset=0;
Serial.println(rfidData);
}
delay(10);
}
}