system
November 27, 2012, 11:30am
1
part of code
void rec_tab(){
byte i=0,chk=0,j=0;
while(1){
if (Serial .available()>0){
in_buff[j] = Serial .read();
chk^=in_buff[j];
j++;
if (j==in_buff[1]+2) break;
lcd.setCursor(0,1);
lcd.print(chk,HEX);
}
}
lcd.setCursor(0,0);
lcd.print(" after break ");
lcd.print(chk,HEX);
}
Why break clear chk ??
Before break LCD display 0xA3 after break 0x00 ??
system
November 27, 2012, 11:37am
2
Have you tried posting down the street at snippets-r-us.com ? Here, we get to see ALL of your code, posted using the code icon (with the #), not the quote icon.
MarkT
November 27, 2012, 12:19pm
3
break isn't clearing chk, your code is changing it. break exits the innermost enclosing loop or switch statement with immediate effect.
KeithRB
November 27, 2012, 4:40pm
4
break does not break out of "ifs", only loops. Your break leaves the while loop.