#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int upButton = 3;
int downButton = 4;
int selectButton = 5;
int menu = 1;
int LedOut1 = 1;
int LedOut2 = 2;
int LedOut3 = 3;
int LedOut4 = 4;
int Timer = 0;
int Timer_1 = 0;
int Timer2 = 0;
int Timer3 = 0;
void setup() {
pinMode(upButton, INPUT_PULLUP);
pinMode(downButton, INPUT_PULLUP);
pinMode(selectButton, INPUT_PULLUP);
pinMode(LedOut1, OUTPUT);
pinMode(LedOut2, OUTPUT);
pinMode(LedOut3, OUTPUT);
pinMode(LedOut4, OUTPUT);
lcd.setCursor(0, 0);
lcd.print("check");
delay(500);
lcd.clear();
lcd.print("check.");
delay(500);
lcd.clear();
lcd.print("check..");
delay(500);
lcd.clear();
lcd.print("check...");
delay(500);
lcd.clear();
}
void loop() {
if (!digitalRead(downButton)){
menu++;
updateMenu();
delay(100);
while (!digitalRead(downButton));
}
if (!digitalRead(upButton)){
menu--;
updateMenu();
delay(100);
while(!digitalRead(upButton));
}
if (!digitalRead(selectButton)){
executeAction();
updateMenu();
delay(100);
while (!digitalRead(selectButton));
}
}
void updateMenu() {
switch (menu) {
case 0:
menu = 1;
break;
case 1:
lcd.clear();
lcd.print(">LED1");
lcd.setCursor(0, 1);
lcd.print(" LED2");
break;
case 2:
lcd.clear();
lcd.print(" LED1");
lcd.setCursor(0, 1);
lcd.print(">LED2");
break;
case 3:
lcd.clear();
lcd.print(">LED3");
lcd.setCursor(0, 1);
lcd.print(" LED4");
break;
case 4:
lcd.clear();
lcd.print(" LED3");
lcd.setCursor(0, 1);
lcd.print(">LED4");
break;
case 5:
menu = 4;
break;
}
}
void executeAction() {
switch (menu) {
case 1:
action1();
break;
case 2:
action2();
break;
case 3:
action3();
break;
case 4:
action4();
break;
}
}
void action1() {
lcd.clear();
lcd.print(">Led #1");
digitalWrite(LedOut1,HIGH);
Timer++;
if(Timer ==2){
digitalWrite(LedOut1,LOW);
Timer=0;
}
else{
digitalWrite(LedOut1,HIGH);
}
delay(1500);
}
void action2() {
lcd.clear();
lcd.print(">Led #2");
digitalWrite(LedOut2, HIGH);
Timer_1++;
if(Timer_1 ==2){
digitalWrite(LedOut2,LOW);
Timer_1=0;
}
else{
digitalWrite(LedOut2,HIGH);
}
delay(1500);
}
void action3() {
lcd.clear();
lcd.print(">Led #3");
digitalWrite(LedOut3, HIGH);
Timer2++;
if(Timer2 ==2){
digitalWrite(LedOut3,LOW);
Timer2=0;
}
else{
digitalWrite(LedOut3,HIGH);
}
delay(1500);
}
void action4() {
lcd.clear();
lcd.print(">led #4");
digitalWrite(LedOut4,HIGH);
Timer3++;
if(Timer3 ==2){
digitalWrite(LedOut4,LOW);
Timer3=0;
}
else{
digitalWrite(LedOut4,HIGH);
}
delay(1500);
}