i am using LPSECURITY card reader connecting to ESP8266 arduino board rx and tx when when i using the below code , it seems shown the bytes to me only . did i do anything wrong ? it should print out the card number .
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
Card number Reading: 6
Card number Reading: 95
Card number Reading: 47
Card number Reading: 51
Card number Reading: 99
Card number Reading: 121
Card number Reading: 61
Card number Reading: 126
Card number Reading: 63
Card number Reading: 6
Card number Reading: 103
Card number Reading: 103
Card number Reading: 102
Card number Reading: 6
thats what i get from serial monitor , it should print out my card id ..
That's what you tell it to, every time the module spits out a byte, you print that byte as decimal and put "Card number Reading: " in front of it.
What do you want it to spit out given the data from above?
septillion:
That's what you tell it to, every time the module spits out a byte, you print that byte as decimal and put "Card number Reading: " in front of it.
What do you want it to spit out given the data from above?
Example the card number was 0318829039 000,61935 . is that possible it print out the card number . as i am using a card reading machine by the function of RS232
Joshtan:
as i am using a card reading machine by the function of RS232
but you are using logic level shifters (i hope) otherwise your ESP would be broken by now.
Example the card number was 0318829039 000,61935
and your result on the serial monitor was what was in the original post ? I can't quite make sense of that.
how about you change the loop() to this:
if (Serial.available()) {
Serial.print("I received: ");
// read the incoming byte:
while (Serial.available()) {
incomingByte = Serial.read();
Serial.print(incomingByte, HEX);
Serial.print(",");
if (!Serial.available()) delayMicroseconds(1200);
}
Serial.println();
}
and if you have 1 more card to scan that would help
Joshtan:
Example the card number was 0318829039 000,61935 .
Is that the number you expect with the card from the start post?
Also, where does the space and comma come from?
Deva_Rishi's code will print it in one go but do note it's blocking code. Aka, I'm not a fan.
septillion:
Deva_Rishi's code will print it in one go but do note it's blocking code. Aka, I'm not a fan.
it is meant for developing and debugging purposes, if you want to do the reception properly have a look at Serial Input Basics by Robin
which unfortunately does not include blocking examples (which can be required in some code, and are usually much more simple to understand for a beginner)
Deva_Rishi:
it is meant for developing and debugging purposes, if you want to do the reception properly have a look at Serial Input Basics by Robin
which unfortunately does not include blocking examples (which can be required in some code, and are usually much more simple to understand for a beginner)
thanks you all i just been touch programming for few month , much more things never touch before after i read the basic i much more understand.
Quick note, although the compiler is more sensitive for capitals than we are, we still like them 
Good luck with the project and happy programming 