well, if I do something like this:
int potPin0 = 0; int potPin1=1; int potPin2=2;// select input pin
int val0 = 0; int val1; int val2;// variable to store the value
int lastVal0 = 0; int lastVal1=0; int lastVal2=0;
//pin0 will be steering wheel
//pin1 will be brake
//pin2 will be gas
void setup()
{
Serial.begin(9600);
}
void loop()
{
//So depending on which pot is turned then it will run this code one pot at a time, <val>
//if two pots are turned almost simultaneously then whichever pot is turned first it runs, then runs second pot immediately after
val0 = analogRead(potPin0);
if(abs(val0-lastVal0) >10)
{
Serial.print("<");
Serial.print(val0);
Serial.println(">");
lastVal0=val0;
}
val1=analogRead(potPin1);
if(abs(val1-lastVal1) > 10)
{
Serial.print("<");
Serial.print(val1);
Serial.println(">");
lastVal1=val1;
}
val2=analogRead(val2);
if(abs(val2-lastVal2) > 10)
{
Serial.print("<");
Serial.print(val2);
Serial.println(">");
lastVal2=val2;
}
}
I would assume it would send as , so only one token at a time. What my question is, since it is not sending <val1,val2,val3> how will I determine which val was sent for which pot if I only send ? I have never used strtok but have read about it since you mentioned it and seems I will need to apply it.