I'm using an RFID reader to read some tags, and using the altSoftSerial library. However, in order to print the tagID to my serial, I need to press enter. And for the love of God I can't figure out why that is. Isn't it possible to check the altSerial.read for a certain ID, and print it when it appears? Cause when I print the serial automatically I just get a lot of 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' noise...
#include <AltSoftSerial.h>
AltSoftSerial altSerial;
char txrxbuffer[255];
char get_readID[] = { 0xAA , 0x00, 0x03, 0x25, 0x26, 0x00, 0x00, 0xBB };
void setup()
{
Serial.begin(9600);
Serial.println("Hit Enter to read the RFID number");
altSerial.begin(9600);
}
void loop() // run over and over
{
int counter = 0;
if (Serial.available()){
Serial.read();
Serial.println("");
for (counter =0 ; counter < 8 ; counter++){
char tagID = get_readID[counter];
altSerial.write(tagID);
}
}
if (altSerial.available())
Serial.print(altSerial.read(),HEX);
}
Thanks for pointing that out, I'm pretty new to the Serial stuff, so I didn't really know what the Serial.available() was returning. I figured it was simply checking if Serial.begin() had been set or smth.
Anyway, I've been trying to get it to work properly for the past 4 hours since you replied. I did get it to print the whole shebang without pressing enter, just not neatly arranged like it is when I leave the Serial.available() part.
This is what I get when I use the Serial.available() part:
And this is what happens when I leave it out:
Is there a way to check the mySerial.read() for one of the tag serials? Cause I really don't know why, if i press enter, it prints only the info I need, and just once. Instead of flooding my serial like the other one. Forgive me for asking all these questions.. I'm intrigued by the complexity.
KevinDamstra:
Cause I really don't know why, if i press enter, it prints only the info I need, and just once. Instead of flooding my serial like the other one.
That would be because of a bug in your code. If you post your current code and explain what you want it to do and what it's actually doing, quite likely somebody will be able to suggest how to fix the bug.
After you read and discarded the byte from the serial port, you printed a carriage return and line feed. After reading a complete tag, you need to again print a carriage return and line feed. Of course, the key is figuring out when you've read a complete tag.