/* 
In this demo there are 2 LEDs connected to the Arduino. 
The blinking rate of the LEDs can be varied by adjusting the 2 potentiometers.
The rate of blinking of each LED is displayed on the LCD display.
*/
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
const int potPin1 = A0;
const int potPin2 = A1;
const int ledPin1 = 2;
const int ledPin2 = 4;
int blinkInterval1 = 0;
int blinkInterval2 = 0;
unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
LiquidCrystal lcd(12, 11, 5, 6, 7, 8);
void setup() {
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  lcd.begin(16, 2);
}
void loop() {
  int pot1 = analogRead(potPin1);
  int pot2 = analogRead(potPin2);
  blinkInterval1 = map(pot1, 0, 1023, 100, 2000);  // LED 1: 100ms to 1000ms
  lcd.setCursor(0, 0);
  lcd.print("LED1:" + String(blinkInterval1) + " ");
  blinkInterval2 = map(pot2, 0, 1023, 100, 2000);  // LED 2: 100ms to 2000ms
  lcd.setCursor(0, 1);
  lcd.print("LED2:" + String(blinkInterval2) + " ");
  
  
  unsigned long currentMillis = millis();
  
  if (currentMillis - previousMillis1 >= blinkInterval1) {
    previousMillis1 = currentMillis;
    digitalWrite(ledPin1, !digitalRead(ledPin1));  
  }
  
  if (currentMillis - previousMillis2 >= blinkInterval2) {
    previousMillis2 = currentMillis;
    digitalWrite(ledPin2, !digitalRead(ledPin2));  
  }
}