int thumbIndex = 23;
int indexMiddle = 22;
int middleRing = 21;
int ringPinkie = 19;
int LED1 = 16;
int LED2 = 4;
int other = 13;

void setup() {

   pinMode(thumbIndex, INPUT);
   pinMode(indexMiddle, INPUT); 
   pinMode(middleRing, INPUT);
   pinMode(ringPinkie, INPUT); 
   pinMode(LED1, OUTPUT);
   pinMode(LED2, OUTPUT);
   pinMode(other, OUTPUT);
   

//   digitalWrite(LED1, HIGH);
//   digitalWrite(LED2, HIGH);
//   digitalWrite(other, HIGH);

   Serial.begin(115200);
   Serial.println();


   }

#define max_buffer 25

void loop() {
  // Primarily we will stimulate motors one to prove it works after we'll work on getting an input and sending it via Bluetooth
   static char chr;
   static char buffer[max_buffer] = {0};
   static int index;
   if (Serial.available()) {
      chr = Serial.read();
      Serial.print("hello.ESP32-WROOM.echo: you typed \"");
      buffer[index++] = chr;
      if (index == (max_buffer-1))
         index = 0;
      Serial.print(buffer);
      Serial.println("\"");
      }

   if (!(digitalRead(indexMiddle)) && !(digitalRead(middleRing)) && !(digitalRead(ringPinkie))) {
       if (digitalRead(thumbIndex)) {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
       }
       else {
        digitalWrite(LED1, LOW);
        digitalWrite(LED2, LOW);
       }
   }
   else if (!(digitalRead(thumbIndex)) && !(digitalRead(middleRing)) && !(digitalRead(ringPinkie))) {
       if (digitalRead(indexMiddle)) {
        digitalWrite(LED1, LOW);
        digitalWrite(LED2, HIGH);
       }
       else {
        digitalWrite(LED1, LOW);
        digitalWrite(LED2, LOW);
       }
   }
   else if (!(digitalRead(thumbIndex)) && !(digitalRead(indexMiddle)) && !(digitalRead(ringPinkie))) {
       if (digitalRead(middleRing)) {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, LOW);
       }
       else {
        digitalWrite(LED1, LOW);
        digitalWrite(LED2, LOW);
       }
   }
   else if (!(digitalRead(thumbIndex)) && !(digitalRead(indexMiddle)) && !(digitalRead(middleRing))) {
       if (digitalRead(ringPinkie)) {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
       }
       else {
        digitalWrite(LED1, LOW);
        digitalWrite(LED2, LOW);
       }
  }

   }