Variable changed without code


hi

this simple code bellow displays difference in variables , b on serial output (ide 1.0.5, deumillanove).
variables should equal , not changed within code, expect serial output should write ok.
this not case, writes "not equal ".
any ideas why ?

regards

dino

/*
  encoder test
  created dino mrvalj 2014
*/
 
#include <wire.h>

int = 0;
int b = 0;

void setup() {
  = 0;
  b = 0;
  wire.begin(); 
  serial.begin(57600); 
  serial.println (" start ");   
}

void loop() {
  /***********************************************************************************
  *  printout not expected
  ***********************************************************************************/
  = b;
  b = a;

 
   if (a=!b) {    
    serial.print ("a: ");  serial.print (a);  serial.print ("   - b: ");  serial.print (b); serial.println ("    not equal !?");
  }
  else {
    serial.print ("a: ");  serial.print (a);  serial.print ("   - b: ");  serial.print (b); serial.println (" ok ");
  }
   
}

hi, try

!=     instead of  =!


tom....... :)


Arduino Forum > Using Arduino > Programming Questions > Variable changed without code


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support