Hi,
When I sent a chain like 'azrty' from my computer to the arduino, i receive it character per character on the arduino.
how to have it in one 'block' to analyse it in the arduino code ??
thanks
seb
Hi,
When I sent a chain like 'azrty' from my computer to the arduino, i receive it character per character on the arduino.
how to have it in one 'block' to analyse it in the arduino code ??
thanks
seb
You'll have to read it character by character. There is no direct serial read functio that reads a completer string or line of text. Declare an array of characters, big enough to hold your text plus a '\0' for end-of-string, than use an index to fill it up, one character at a time.
//read a string from the serial and store it in an array
//you must supply the array variable - will return if timeOut ms passes before the sting is read so you should
//check the contents of the char array before making any //assumptions.
void readSerialString (char *strArray,long timeOut)
{
long startTime=millis();
int i;
while (!Serial.available()) {
if (millis()-startTime >= timeOut) {
return;
}
}
while (Serial.available() && i < serInLen) {
strArray = Serial.read();