Hi
This simple code bellow displays difference in variables A and B on serial output (IDE 1.0.5, deumillanove).
Variables should be equal and are not changed within code, so I expect that serial output should always write OK.
This is not the case, it writes "not equal ".
Any ideas why ?
regards
Dino
/*
Encoder test
Created by Dino Mrvalj 2014
*/
#include <Wire.h>
int A = 0;
int B = 0;
void setup() {
A = 0;
B = 0;
Wire.begin();
Serial.begin(57600);
Serial.println (" Start ");
}
void loop() {
/***********************************************************************************
- printout not as expected
***********************************************************************************/
A = 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 ");
}
}