I have this gorve RFID reader:
seeedstudio.com/depot/Grove- … -1008.html
and this seeduino lite based on 32U4
seeedstudio.com/wiki/Seeeduino_Lite
the RFID reader is set in UART mode.
If I connect to software serial with 10 as RX, 11 as TX, I got nothing. code as below:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
But, if I connect RFID to serial1, I got the reading, code as following:
static long baud = 9600;
void setup() {
//pinMode(DTR_PIN, OUTPUT);
//digitalWrite(DTR_PIN, LOW);
Serial.begin(baud);
// while the serial stream is not open, do nothing:
while (!Serial) ;
Serial1.begin(baud);
}
void loop() {
// copy from virtual serial line to uart and vice versa
if (Serial.available()) {
char c = (char)Serial.read();
Serial1.write©;
}
if (Serial1.available()) {
char c = (char)Serial1.read();
Serial.write©;
}
}
what is wrong?