Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int encoder0PinA = 7;
- int encoder0PinB = 8;
- 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.println (encoder0Pos);
- // Serial.print ("/");
- }
- encoder0Pos = encoder0Pos % 1024;
- encoder0PinALast = n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement