I have been trying to get this to work for a few days.
What i have at the moment is TouchOSC installed on my Iphone sending commands to a processing program, which in turn simplify's them and sends them off to my arduino through serial.
This is where my problem is the commands get there and I can print them out easy enough. They arrive correctly. Format is t11 or t10 (t for toggle control, then # for id of control changed, the last # is on or off (1 or 0)
Now when I try and break this down with if statements it never seams to work. I know the data is correct when it gets to the arduino.
I need to test if the first char is a 't' simple if statement
if(Serial.read() == 't')
before this i test if
is true then through similar if statements i test if next is the number '1' or '2' for the control id, then if number is on or off, '1' or '2'
When i test this in Serial monitor or with real data off my phone never seam to get into the loops or will get it to one and not the other. Some times i can tweak it to get into all of them to switch the LED on, but then won't turn it off or vica-versa
Can anyone please give me an example of the logic that i need to use, i have also tried using switch statements for the ID doesn't seam to make much difference