I have a program in Visual C++ that will send a string of serial data to my Arduino. There will be two numbers, separated by a symbol. I can change the symbol in the code if it's necessary. The numbers are each 0-100. For example, a few strings could look like
0X0
100X100
15X25
35X95
You get the idea.
I need to read this data into two separate variables in the Arduino so I can display each individually, as well as perform calculations on them.
Here is some example code I wrote, but I realized quickly I'm in over my head on this one.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(){
lcd.begin(2, 24);
Serial.begin(115200);
}
void loop()
{
int i=0;
int j=0;
char var1 [3];
char var2 [3];
if (Serial.available()) {
delay(100);
i = 0;
j = 0;
while (Serial.available()){
if (Serial.read()!="X"){
var1[i] = Serial.read();
i++;}
else{
var2[j] = Serial.read();
j++;}
}
}
lcd.clear();
lcd.write(var1[]);
setCursor(0,1);
lcd.write(var2[]);
}
I'm sure this isn't anywhere close to correct, it obviously won't compile due to me not having a clue what I'm doing with character arrays, but am I at least on the right track?
Any help is greatly appreciated, just a push in the right direction would be wonderful.
Thanks,
Steve