I really hope I am doing this wrong!

After many frustrating hours spent debugging a routine, I have finally shaved it down to this! This will NOT print correctly. Why? I hope this is something trivial or might there be a problem with IDE. Mac 10.6.2 arduino 17

byte a[1]; void setup(){

Serial.begin(9600);

a[1] =54;

Serial.println(a[1], DEC); Serial.println(a[1], DEC); }

void loop(){ }

first print is 54. //good second print is 56. //very bad It will work if non array var is used or if the array is moved into setup.

This creates a different outcome.......still wrong.

byte a[1]; byte b;

void setup(){

Serial.begin(9600);

a[1] =54; b=25;

Serial.println(a[1], DEC); Serial.println(a[1], DEC); Serial.println(b, DEC); Serial.println(b, DEC); }

void loop(){ }

It looks like the references to a[1] are past the end of a[], which is declared to be one element in length, whose name would therefore be a[0], would it not?

-br

It looks like the references to a[1] are past the end of a[], which is declared to be one element in length, whose name would therefore be a[0], would it not?

-br

Agreed. That looks like the problem.

Also use the # button in the message window when you want to post code.

Aarrgh… thanks guys. my self inflicted injuries will heal soon. (not really very deep) Obviously didn’t have an escape line in mental loop! kept assuming A[1] means 2 item (0,1)

for(int i=1; i<=,100, 1++){ // in red chalk on blackboard
print “Consider EVERY line, stupid. It ain’t THAT hard.”
}
Again, thanks Forum Guys.

for(int  i=1; i<=[glow],[/glow]100, [glow]1++[/glow]){                                         // in  red chalk on blackboard
[glow]Serial.[/glow]print[glow]([/glow]"Consider EVERY line, stupid. It ain't THAT hard."[glow]);[/glow]
}

Well, maybe it is hard. :wink:

Well there is more wrong with it then that.

need a ';' after the 100 not a ','.