#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
int up = A0;
int down = A1;
int out1 = 6;
int out2 = 7;
int volt = 50;
void setup() {
lcd.begin(16, 2);
lcd.setCursor(4, 0);
lcd.print("WELCOME");
delay(500);
lcd.clear();
pinMode(out1, OUTPUT);
pinMode(out2, OUTPUT);
pinMode(up, INPUT);
pinMode(down, INPUT);
}
void loop() {
lcd.setCursor(0, 0);
lcd.print("Volt :");
lcd.setCursor(7, 0);
lcd.print(volt);
digitalWrite(out1, HIGH);
digitalWrite(out2, HIGH);
delay(volt / 2);
digitalWrite(out1, LOW);
digitalWrite(out2, LOW);
delay(volt / 2);
if (volt < 60) {
if (digitalRead(up) == HIGH) {
delay(200);
if (digitalRead(up) == LOW) {
analogWrite(out1, volt);
volt = volt + 1;
delay(100);
}
}
}
if (volt > 50) {
if (digitalRead(down) == HIGH) {
delay(200);
if (digitalRead(down) == LOW) {
analogWrite(out2, volt); // Use out2 for "down" condition
volt = volt - 1;
delay(100);
}
}
}
// lcd.clear();
}