Hi All,
What Method would you use to extract information form a serial message sent from a PC?
For example if I sent the string: "Value1: 45 Value2: 56" as one serial message from Visual Basic, how do I get the Arduino to store just "45" in one variable and "56" in a different variable?
Read the serial data in, store in an array, pick off the bits you want.
Value1: 45 Value2: 56 is 21 bytes, 0 to 20, so:
if (Serial.available() > 20){ // at least 21 bytes came in
for (x=; x<=21; x=x+1){
arrayStream[x] = Serial.read();
}
// now find the data, convert from ascii to decimal, www.asciitable.com, and combine
firstValue = ((arrayStream[8]-48) *10) + (arrayStream[9]-48);
secondValue = ((arrayStream[19]-48) * 10) + (arrayStream[20]-48);
// and print it back to test it out:
Serial.println(firstValue);
Serial.println(secondValue);
}
Can be a little smarter about it, keep reading until you see a 'V' as a character, then store 20 more bytes, get it sync with the transmitter
Then use <EEPROM.h> library to store in EEPROM
Thank you.
This worked exactly how I wanted it to.
Sorry for the late reply.