// https://wokwi.com/projects/417713987244523521
// From https://github.com/PaulStoffregen/Encoder/blob/master/examples/Basic/Basic.ino
// pin assingment modified to use 1 interrupt pin
// See also 
//  https://wokwi.com/projects/417713987244523521 -- Basic
//  https://wokwi.com/projects/417713685639409665 -- TwoKnobs
//  https://docs.wokwi.com/parts/wokwi-ky-040 -- Wokwi's encoder
//  https://forum.arduino.cc/t/wokwi-simulations-for-arduino-built-in-examples/1304754/9 -- forum discussion

/* Encoder Library - Basic Example
 * http://www.pjrc.com/teensy/td_libs_Encoder.html
 *
 * This example code is in the public domain.
 */

#include <Encoder.h>

// Change these two numbers to the pins connected to your encoder.
//   Best Performance: both pins have interrupt capability
//   Good Performance: only the first pin has interrupt capability
//   Low Performance:  neither pin has interrupt capability
Encoder myEnc(2, 6);
//   avoid using pins with LEDs attached

void setup() {
  Serial.begin(9600);
  Serial.println("Basic Encoder Test:");
}

long oldPosition  = -999;

void loop() {
  long newPosition = myEnc.read();
  if (newPosition != oldPosition) {
    oldPosition = newPosition;
    Serial.println(newPosition);
  }
}
Loading chip...chip-scope