Go Down

Topic: Serial Reading - Char Limit? (Read 951 times) previous topic - next topic

jschabs

Is there a limit to the number of char inputs the Serial can read at one time?

Constantin

#1
Jul 12, 2012, 05:21 pm Last Edit: Jul 12, 2012, 05:23 pm by Constantin Reason: 1
The serial buffer as of Arduino 1.0+ is 64 bytes.

If you're using SoftSerial, only one softserial connection can receive data at a given time.

majenko

Yes.  One.

Serial reads one character at a time from the input.

It places those characters, one at a time, into an input buffer - the size of which depends on the Arduino you are using.

You then read those characters from the input buffer using the Serial.read() function, which returns the characters from the buffer one at a time.

If you want to read more than one at a time you can use the Serial.readBytes(buffer,len) function to read up to "len" characters from the serial buffer into the memory pointer to by "buffer":

Code: [Select]

char buf[10];

Serial.readBytes(buf,9);


- that will read 9 bytes into the variable "buf", leaving room for one extra character for the null-termination for the string.

jschabs

Okay, I suppose I should have asked how many characters the Serial can hold. It's 64 bytes? Does that come out to about 64 characters?

PaulS

Quote
It's 64 bytes? Does that come out to about 64 characters?

No. It comes out to exactly 64 characters. If using Arduino IDE 1.0+. On older versions, the buffer size was 128 characters.

Go Up