Last active
February 12, 2023 05:13
-
-
Save mwhooker/b6aab659e9ade125c418efd104767eca to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <Wire.h> | |
#include "rgb_lcd.h" | |
rgb_lcd lcd; | |
const int colorR = 255; | |
const int colorG = 0; | |
const int colorB = 0; | |
// Rocoder library: https://github.com/PaulStoffregen/Encoder | |
// This optional setting causes Encoder to use more optimized code, | |
// It must be defined before Encoder.h is included. | |
#define ENCODER_OPTIMIZE_INTERRUPTS | |
#include <Encoder.h> | |
/* | |
#define ENCODER_PIN1 2 | |
#define ENCODER_INT1 digitalPinToInterrupt(ENCODER_PIN1) | |
#define ENCODER_PIN2 3 | |
#define ENCODER_INT2 digitalPinToInterrupt(ENCODER_PIN2) | |
*/ | |
Encoder myEnc(2,3); | |
void setup() | |
{ | |
// set up the LCD's number of columns and rows: | |
lcd.begin(16, 2); | |
lcd.setRGB(colorR, colorG, colorB); | |
//Serial.begin(9600); | |
delay(1000); | |
} | |
long oldPosition = -999; | |
void loop() | |
{ | |
long newPosition = myEnc.read(); | |
if (newPosition != oldPosition) { | |
oldPosition = newPosition; | |
//Serial.println(newPosition); | |
} | |
lcd.clear(); | |
// print the number of seconds since reset: | |
lcd.print(newPosition); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment