Go Down

Topic: Odd Behavior (Read 587 times) previous topic - next topic


Okay, this is the code:

Code: [Select]

 Send numbers to serial out

void setup()
 // wait for any serial activity to start
 while (!Serial.available())
 // then send a comma separated file of x,y data
 for (byte i=0;i<256;i++)

void loop()


I enter a character, it starts as expected but never stops.  It runs over and over like it was in the loop section instead of the setup section.


Aug 02, 2010, 02:20 am Last Edit: Aug 02, 2010, 11:10 pm by programmer Reason: 1
The problem comes because the byte data type can only hold a number from 0 to 255. When it reaches 255, it rolls over to 0, and so never becomes 256 and as a result the loop will never stop.


how stupid of me - thanks!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131