#include <SimpleRotary.h>


#define ENCODER_1_CLK 2
#define ENCODER_1_DT  3
long encoder1=0;
#define ENCODER_2_CLK 8
#define ENCODER_2_DT  9

#define ENCODER_3_CLK 6
#define ENCODER_3_DT 7

#define ENCODER_4_CLK 4
#define ENCODER_4_DT 5


#define ENCODER_5_CLK 2
#define ENCODER_5_DT 3


SimpleRotary rotary1(ENCODER_1_CLK,ENCODER_1_DT,0);
SimpleRotary rotary2(ENCODER_2_CLK,ENCODER_2_DT,0);
SimpleRotary rotary3(ENCODER_3_CLK,ENCODER_3_DT,0);
SimpleRotary rotary4(ENCODER_4_CLK,ENCODER_4_DT,0);
SimpleRotary rotary5(ENCODER_5_CLK,ENCODER_5_DT,0);


void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Hello, ESP32-S3!");
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(10); // this speeds up the simulation
    // 0 = not turning, 1 = CW, 2 = CCW
  int i1 = rotary1.rotate();
  if ( i1 == 1 ) {
    Serial.print("CW 1: ");
    encoder1++;
    Serial.print(rotary1.rotate());
    Serial.print(": ");
    Serial.println(encoder1);
    
  }
  if ( i1 == 2 ) {
    Serial.print("CCW 1: ");
    encoder1--;
    Serial.print(rotary1.rotate());
    Serial.print(": ");
    Serial.println(encoder1);
    
  }
    int i2 = rotary2.rotate();
  if ( i2 == 1 ) {
    Serial.println("CW 2");
  }
  if ( i2 == 2 ) {
    Serial.println("CCW 2");
  }
    int i3 = rotary3.rotate();
  if ( i3 == 1 ) {
    Serial.println("CW 3");
  }
  if ( i3 == 2 ) {
    Serial.println("CCW 3");
  }
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
encoder1:CLK
encoder1:DT
encoder1:SW
encoder1:VCC
encoder1:GND