digikey part number: 118-PEC11R-4320F-S0012-ND https://www.digikey.com/en/products/detail/bourns-inc/PEC11R-4320F-S0012/4699235?so=84473212&content=productdetail_US&mkt_tok=MDI4LVNYSy01MDcAAAGP7gCMSmK3S7iQMFn5oT0O7WjvWYwZCCJSnY_UqbFVAni8uOG82dcPK6wfp3T7Dy_SS-4I20sn1ZHBDY0ZDDaqZXyvshl6x9CQ6nFVvuls
https://github.com/davecheney/gpio/blob/master/gpio_linux.go
https://raspberrypi.stackexchange.com/questions/118349/what-is-the-proper-way-to-debounce-a-gpio-input https://www.digikey.com/en/articles/how-to-implement-hardware-debounce-for-switches-and-relays
AZDelivery I2C 0.96-inch OLED Display • Compatible with Arduino SSD1306 & Raspberry Pi • Set of 3 • 128x64 Pixels IIC 3.3V 5V White Character Screen Module https://www.amazon.com/gp/product/B074N9VLZX/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
Rotary encoder decoding using two interrupt lines. Most Arduino boards have two external interrupts, numbers 0 (on digital pin 2) and 1 (on digital pin 3).
Program sketch is for SparkFun Rotary Encoder sku: COM-09117 Connect the middle pin of the three to ground. The outside two pins of the three are connected to digital pins 2 and 3
volatile int number = 0; // Testnumber, print it when it changes value,
// used in loop and both interrupt routines
int oldnumber = number;
volatile boolean halfleft = false; // Used in both interrupt routines
volatile boolean halfright = false;
void setup(){
Serial.begin(9600);
pinMode(2, INPUT);
digitalWrite(2, HIGH); // Turn on internal pullup resistor
pinMode(3, INPUT);
digitalWrite(3, HIGH); // Turn on internal pullup resistor
attachInterrupt(0, isr_2, FALLING); // Call isr_2 when digital pin 2 goes LOW
attachInterrupt(1, isr_3, FALLING); // Call isr_3 when digital pin 3 goes LOW
}
void loop(){
if(number != oldnumber){ // Change in value ?
Serial.println(number); // Yes, print it (or whatever)
oldnumber = number;
}
}
void isr_2(){ // Pin2 went LOW
delay(1); // Debounce time
if(digitalRead(2) == LOW){ // Pin2 still LOW ?
if(digitalRead(3) == HIGH && halfright == false){ // -->
halfright = true; // One half click clockwise
}
if(digitalRead(3) == LOW && halfleft == true){ // <--
halfleft = false; // One whole click counter-
number--; // clockwise
}
}
}
void isr_3(){ // Pin3 went LOW
delay(1); // Debounce time
if(digitalRead(3) == LOW){ // Pin3 still LOW ?
if(digitalRead(2) == HIGH && halfleft == false){ // <--
halfleft = true; // One half click counter-
} // clockwise
if(digitalRead(2) == LOW && halfright == true){ // -->
halfright = false; // One whole click clockwise
number++;
}
}
}