Hi guys
Have some questions here. I have an Arduino board, with multiple input sensors and output LEDs.
I'm sending data every 30 seconds to a visual basic 2010 program. In this program, I will also send signals to the Arduino board to turn on the LED light, and dimming them.
From my arduino, I send data like this, "s1: value, s2: value, d1: value, d2: value, etc..." where s: is analog input, and d: is digital input.
And since I wanna send setpoint such as "k1: 255, w1: 1, z1: time, etc..." where k: is a "analog" value and w: is high/low value.
The problem is when I receive data from my computer. Then I don't know how to split my data, to determ what is what.
Cause since I have various data sending, I need to split my data, find the first letter in the array, then remove the space between letters and remove the 3 first letters so I only have my values.
In vb this is the code:
Code:
For i = 0 To UBound(aryTextFile)
Dim countTextChar(i) As Integer
Dim myLeft(i) As String
Dim myInput(i) As String
Dim myText(i) As String
countTextChar(i) = Len(aryTextFile(i)) ' count letters in array
myInput(i) = Microsoft.VisualBasic.Left(aryTextFile(i), 1) ' find the first letter
myLeft(i) = Microsoft.VisualBasic.Left(aryTextFile(i), 3) ' find the 3 first letters
If myInput(i) = "s" Then
If myLeft(i) = "s1:" Then
myText(i) = Replace(aryTextFile(i), myLeft(i), "")
s1.Text = myText(i) & TempPrefix
End If
'And here comes the rest of the values you want to display in form.
End If
Next i
arduino C code:
Code:
void readSerialString () {
char sb;
if(Serial.available()) {
//Serial.print("reading Serial String: "); //optional confirmation
while (Serial.available()){
sb = Serial.read();
serInString[serInIndx] = sb;
serInIndx++;
//Serial.println(sb); //optional confirmation
}
//Serial.println(sb);
}
}
So this is my problem. I cant figure out how to determ what kind of data I recieve, and use this data later in arduino program.
Hope this was sufficiently explained.
Best,
Andy