#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);

#define pin_S0 26  // Assign GPIO pin numbers for S0, S1, S2, and S3
#define pin_S1 25
#define pin_S2 33
#define pin_S3 32
#define pin_analog 36 // Assign the analog pin of ESP32 connected to the multiplexer

int adc0,adc1,adc2,adc3,adc4,adc5,adc6,adc7,adc8,adc9,adc10,adc11,adc12,adc13,adc14,adc15;

void setup() 
{
  Serial.begin(9600);
  lcd.init();
  lcd.init(); // Inisialisasi LCD
  lcd.backlight(); // Nyalakan backlight LCD

  pinMode(pin_S0, OUTPUT);
  pinMode(pin_S1, OUTPUT);
  pinMode(pin_S2, OUTPUT);
  pinMode(pin_S3, OUTPUT);
  
}

void loop()
{
  digitalWrite(pin_S0, HIGH);
  digitalWrite(pin_S1, HIGH);
  digitalWrite(pin_S2, HIGH);
  digitalWrite(pin_S3, HIGH);
 adc15 = analogRead(pin_analog);

  delay(100);
  digitalWrite(pin_S0, LOW);
  digitalWrite(pin_S1, HIGH);
  digitalWrite(pin_S2, LOW);
  digitalWrite(pin_S3, HIGH);
 adc10 = analogRead(pin_analog);

    delay(100);
    lcd.setCursor(0,0);
    lcd.print(adc15);
    lcd.print("  ");
    lcd.setCursor(0,1);
    lcd.print(adc10);
    lcd.print("  ");
    delay(100);
}