Created
August 19, 2022 21:25
-
-
Save afternoon/1f60807fe06718c8bb0b9b26f5db3216 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <RotaryEncoder.h> | |
#define PIN_IN1 2 | |
#define PIN_IN2 3 | |
RotaryEncoder encoder(PIN_IN1, PIN_IN2); | |
int lastPos = 0; | |
void setup() { | |
Serial.begin(115200); | |
} | |
void loop() { | |
encoder.tick(); | |
int newPos = encoder.getPosition(); | |
if (lastPos != newPos) { | |
Serial.printf("encoder new position: %d\n", newPos); | |
lastPos = newPos; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment