Hello, I am a beginner and I am using grove shield. I post here because it looks like a bug or something missing on my side concerning programming. I just wanted to test a knob on analog A0 input and output to serial port only when the value changes… The code is this:
int knob = A0;
int test_value = 0.;
int knob_level = 0.;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
knob_level = analogRead(knob);
if (test_value != knob_level) {
int test_value = knob_level;
Serial.print("test_value = ");
Serial.println(test_value);
Serial.print("knob_level = ");
Serial.println(knob_level);
}
}
It just keep sending out values even if the knob is not moving (and so the new and old value are the same) it works only for ZERO… am i missing something?
Thanks a lot, sorry for the newbie question