Confusing bug


hi everyone,

i'm hardware designer, project i'm working on @ work requires me write software. i've got small snippit of code not working, , have no idea why.

code: [select]
  if (receivedchars[7] != 66 || receivedchars[7] != 68)     //66 = change disp, 68 = change brightness
  {
    serial.print("invalid command");
    serial.print('\n');
    serial.write(receivedchars[7]);
  }
  else


when run code, get;

code: [select]
invalid command
66


"invalid command" not appear anywhere else in code, must entering if statement. however, if entering if, receivedchars[7] couldn't 66, is.

does have idea might going on?

thank you!

i'm using hterm input , output data on usb arduino

however, if entering if, receivedchars[7] couldn't 66, is.
consider logic:
code: [select]
if (receivedchars[7] != 66 || receivedchars[7] != 68)
since receivedchars[7] can never 66 , 68 simultaneously true. think meant:
code: [select]
if (receivedchars[7] != 66 && receivedchars[7] != 68)


Arduino Forum > Using Arduino > Project Guidance > Confusing bug


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor