Pages: 1 [2]   Go Down
Author Topic: Processing and teensy arduino problem  (Read 2416 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50098
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
arduino IDE doesn't like "if(serial.available()>=4);
Why are you putting a semicolon at the end of an if statement? That forms the body of the if statement, and is, effectively a no-op. Do nothing if the statement is true. Do nothing if the statement is false.

By the way, surely you know that the Serial instance uses a capital S.
Logged

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 361
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello

i have numbers in black window of processing when i run these 3 lines but only with this line in arduino IDE:
if(serial.available());

but my strip led light in wrong colour, only white with glitter

arduino IDE doesn't like "if(serial.available()>=4);


Your arduino is expecting 4 bytes at a time, the original code you posted was correct.  Proofread this part VERY carefully.  If "the IDE doesn't like it" and shows an error when you hit "Verify", then proofread it again VERY carefully smiley
Code:
//protocol expects data in format of 4 bytes
//(xff) as a marker to ensure proper synchronization always
//followed by red, green, blue bytes
if (Serial.available()>=4) {
   if(Serial.read() == 0xff){
      red = Serial.read();
      green= Serial.read();
      blue = Serial.read();
   }
}
Logged

Pages: 1 [2]   Go Up
Jump to: