I have a question in the below code (taken from the RotaryEncoders page in the playground). Specifically: "int encoder0PinALast = LOW;" is it possible for an int to have a value of "LOW" (or "HIGH")?
A little clarity here would be appreciated.
Thank you.
Dustin
int val;
int encoder0PinA = 3;
int encoder0PinB = 4;
int encoder0Pos = 0;
int encoder0PinALast = LOW;
int n = LOW;
void setup() {
pinMode (encoder0PinA,INPUT);
pinMode (encoder0PinB,INPUT);
Serial.begin (9600);
}
void loop() {
n = digitalRead(encoder0PinA);
if ((encoder0PinALast == LOW) && (n == HIGH)) {
if (digitalRead(encoder0PinB) == LOW) {
encoder0Pos--;
} else {
encoder0Pos++;
}
Serial.print (encoder0Pos);
Serial.print ("/");
}
encoder0PinALast = n;
}
If you dont remember the value of any of those terms, just use Serial.write(HIGH);
then in the console see what it says
true, high, output = 1
false, low, input = 0