RFID shield: SparkFun RFID Evaluation Shield - 13.56MHz - DEV-10406 - SparkFun Electronics
RFID tag (blank): RFID Tag - Transparent MIFARE Classic® 1K (13.56 MHz) - SEN-10128 - SparkFun Electronics?
Arduino Board: ATMega Lite/ATMega 328
I have all the ground pins wired the the Arduino ground pin and I have "5v" wired to pin 6 (named "D6") for turning on manually. SoftwareSerial had a note about pins: "Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69"
I used pin 13 for TX (named "B5") and pin 12 for RX (named "B4"). Here is my code:
#include <Streaming.h>
#include <SoftwareSerial.h>// Pin numbers.
const int RX = 12;
const int TX = 13;
const int LED_ORANGE = 7;
const int LED_BLUE = 6;
const int TAG_IN = 14;
const int SHIELD = 6;// Timing
const int SECOND = 1000;
const int BAUD_RATE = 19200 ;SoftwareSerial mySerial(RX, TX);
void setup(){
pinMode(SHIELD, OUTPUT);Serial.begin(BAUD_RATE);
mySerial.begin(BAUD_RATE);Serial << "Powering RFID Reader..." << endl;
digitalWrite(SHIELD, HIGH);Serial << "Initialized...";
}void loop(){
getRFIDInput();
writeToRFID("HELLO!");
delay(10);
}void getRFIDInput(){
int c = mySerial.read();
if (c != -1){
Serial << "Read character " << (char) c << endl;
}
}/**
- write a message to an RFID tag.
- @param message the message to write.
*/
void writeToRFID(char message[]){
mySerial.write(message);
}
The problem is that the variable "c" (in method "getRFIDInput") is always -1 so I'm not reading a character. Did I write to it correctly? I've been following different tutorials online. The only variations seem to be they're changing the format in which the data is; the basis, though seems to be SoftwareSerial.read() and SoftwareSerial.write().
So confuzzled. :~