I'm trying to learn how to evaluate if a value is increasing or decreasing. In this case I'm using a potentiometer mapped from 0 - 14. Basically I need it to look at the current value, and if the current value is increasing print one thing, and if the value is decreasing print something else.
Here's what I have so far, I know its not right, but its a start.
Thoughts?
Thank you.
void setup() {
Serial.begin(9600);
}
void loop() {
int val = analogRead(A0); // read the input on analog pin 0:
val = map(val, 0, 1023, 0, 14); // map the vlaues to new values
Serial.println(val); // print those values
delay(1); // delay by a second.
// sudo code
if (val++) {
Serial.println("up");
} else if (val--){
Serial.print("down");
}else{
// do nothing
}
}// end loop