Storing Changing Variables in Array
I am trying to store constantly changing variables into a character array,while communicating over a serial port, and I am not getting the consistency that I need.
Here is the code:
Code:
Code:
char str[4];
if(Serial.available())
{
for(int i=0;i<3;i++)
{
str[i] = Serial.read();
}
}
Is this the best way to read in the variables that I need? I am reading multiple variables at a time,using multiple arrays, which could be two to three digits in length each and are sent next to each other as a whole number. Any help would be greatly appreciated. Thanks.