SoftSerial Shield is connected to the Software UART:D2&D3
*/
#include
<SoftwareSerial.h>
SoftwareSerial SoftSerial(2, 3);
unsigned char
buffer[64];
int
count = 0;
// counter for buffer array
void
setup()
{
SoftSerial.begin(9600);
Serial.begin(9600);
// the Serial port of Arduino baud rate.
}
void
loop()
{
// if date is coming from software serial port ==> data is coming from SoftSerial shield
if
(SoftSerial.available())
{
while(SoftSerial.available())
{
buffer[count++] = SoftSerial.read();
if(count == 64)break;
}
Serial.write(buffer, count);
clearBufferArray();
// call clearBufferArray function to clear the stored data from the array
count = 0;
// set counter of while loop to zero
}
if
(Serial.available())
or notebook
SoftSerial.write(Serial.read());
}
void
clearBufferArray()
{
// clear all index of array with command NULL
for
(int
i=0; i<count; i++)
{
buffer[i]=NULL;
}
}
Step 2. Open the Serial Monitor, the card information can be displayed as
shown below:
// buffer array for data receive over serial port
// the SoftSerial baud rate
// reading data into char array
// writing data into array
// if no data transmission ends, write buffer to hardware serial port
// if data is available on hardware serial port ==> data is coming from PC
// write it to the SoftSerial shield
// function to clear buffer array
Need help?
Do you have a question about the Grove-125KHz RFID Reader and is the answer not in the manual?