#include <Wire.h>
#include <LiquidCrystal_I2C.h>

const int ledPins[] = {19, 5, 15, 18, 2}; // Pins connected to the LEDs in the desired pattern
const int numLEDs = sizeof(ledPins) / sizeof(ledPins[0]);
const int potentiometerPin = 34; // Pin connected to the potentiometer

volatile int transitionDelay = 1000; // 1-second transition delay
volatile int currentIndex = 0;

LiquidCrystal_I2C lcd(0x27, 16, 2);  // Change the address (0x27) based on your LCD module

void IRAM_ATTR handlePotentiometerChange() {
  int potValue = analogRead(potentiometerPin);
  transitionDelay = map(potValue, 0, 4095, 500, 3000);  // Adjust the speed range as needed
}

void setup() {
  for (int i = 0; i < numLEDs; i++) {
    pinMode(ledPins[i], OUTPUT);
  }

  attachInterrupt(digitalPinToInterrupt(potentiometerPin), handlePotentiometerChange, CHANGE);

  Serial.begin(115200);
  Wire.begin();
  lcd.begin(16, 2);
  lcd.backlight();
}

void loop() {
  digitalWrite(ledPins[currentIndex], HIGH);  // Turn on the current LED

  delay(transitionDelay);

  digitalWrite(ledPins[currentIndex], LOW);  // Turn off the current LED

  currentIndex = (currentIndex + 1) % numLEDs; // Move to the next LED

  delay(transitionDelay);

  // Display the transition delay on LCD
  lcd.setCursor(0, 0);
  lcd.print("Transition Delay:");
  lcd.setCursor(0, 1);
  lcd.print(transitionDelay / 1000); // Print in seconds

  // Other code or tasks can be performed here
}
$abcdeabcde151015202530354045505560fghijfghij