Hello everyone
I just an Arduino Uno and a RFID module from here http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=90_93&products_id=2156 and I had a problem,in the manual it says that the module is wired to the arduino to the Pin 2 and 3 for serial communication (UART), actually the module didn't work The PC/Arduino communication works fine but the module can't communicate with arduino(I checked the RX and TX LEDs).
Can anybody help me with that that would be awesome
Thank you in advance
Here is the COde
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //pin2 Rx, pin3 Tx
int CMD[64];
int comlen =0;
int out_flag =0;
void setup()
{
Serial.begin(9600);
mySerial.listen();
Serial.println("Serial number will be displayed here if a card is detected by the module:\n");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
delay(10);
mySerial.write(0x02); //Send the command to RFID, please refer to RFID manual
}
void loop() // run over and over
{
while (Serial.available())
{
int a = SerialReadHexDigit();
//Serial.println(a);
if(a>=0){
CMD[comlen] = a;
comlen++;
}
delay(10);
}
for(int i=0; i<comlen; i+=2){
int c = mySerial.write( CMD[i]*16 + CMD[i+1]);
}
comlen =0;
while (mySerial.available()) {
byte C = mySerial.read();
if (C<16) Serial.print("0");
Serial.print(C ,HEX); //Display the Serial Number in HEX
Serial.print(" ");
out_flag =1;
}
if (out_flag >0) {
Serial.println();
out_flag = 0;
}
}
int SerialReadHexDigit()
{
byte c = (byte) Serial.read();
if (c >= '0' && c <= '9') {
return c - '0';
} else if (c >= 'a' && c <= 'f') {
return c - 'a' + 10;
} else if (c >= 'A' && c <= 'F') {
return c - 'A' + 10;
} else {
return -1; // getting here is bad: it means the character was invalid
}
}
Please reply I really need help !!
I checked the RX and TX LEDs.
what do you mean?
you checked the softserial TX RX or hardware Serial?
did the leds flash?
Sorry I don't understand because there is only one pair of RX TX LEDs on Arduino!