Hi all!
I am rather new to Arduino and also to MATLAB and I would like to ask for help.
I developed a code for the arduino, which reads serial input data, and stores the integer values in it.
It works perfectly when I write all numbers in the serial monitor (seperated by commas) and send it as one.
But I can not make MATLAB to send a similar message (multiple integer values, seperated by anything).
(My probe array what I copy-paste in to the serial monitor is the following:
"10,0,15,1,1,0,0,150,0,0,1,0,0,150,0,0,1,0,0,150,0,0,0,0,0,33,0,0,0,0,0,33,0,0,0,0,0,33,0,0,170")
Here is my Arduino code:
void loop()
{
if (Serial.available()>0) // Process incoming message if serial data available
{
for (int i=0; i<41; i++) // Load the 34 integers to the temporary array.
{
SERIAL_DATA[i]=Serial.parseInt(); // parseInt() function loads first valid integes.
} // Numbers may be separated anything other than numbers.
for (int j=0; j<41; j++)
{
Serial.print("SERIAL_DATA[");
Serial.print(j);
Serial.print("]= ");
Serial.println(SERIAL_DATA[j]);
}
while(Serial.available()>0) // Reads out leftover data (like: '/n', etc.).
{
Serial.read();
}
}
How can I send the same (or similar) message to my arduino?
(If I am correct, my code only needs 41 integer values, seperated by anything other then numbers.)
Thank you very much in advance!
Zancot