#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#define tombol1 12
#define tombol2 11
#define tombol3 10
int menu,submenu,
stat1,stat2,stat3,
statmenu;
void setup()
{
Serial.begin(115200);
lcd.init();
lcd.backlight();
lcd.setCursor(4,0);
lcd.print("~POLNES~");
lcd.setCursor(7,1);
lcd.print("TI");
delay(1000);
lcd.clear();
pinMode(tombol1, INPUT_PULLUP);
pinMode(tombol2, INPUT_PULLUP);
pinMode(tombol3, INPUT_PULLUP);
}
void loop()
{
stat1 = digitalRead(tombol1);
stat2 = digitalRead(tombol2);
stat3 = digitalRead(tombol3);
if(statmenu == 0)
{
mainmenu();
}
if(statmenu == 1)
{
mainsubmenu();
}
//Serial.println(menu);
delay(100);
}
void mainmenu()
{
if(stat1 == 0)
{
menu++;
}
if(stat2 == 0)
{
menu--;
}
if(menu >= 4)
{
menu = 0;
}
if(menu <= -1)
{
menu = 3;
}
if(menu == 0)
{
lcd.setCursor(0,0);
lcd.print("START ");
lcd.setCursor(0,1);
lcd.print("PRESS START");
}
if(menu == 1)
{
lcd.setCursor(0,0);
lcd.print("SETTING ");
lcd.setCursor(0,1);
lcd.print("PRESS START");
if(stat3 == 0)
{
statmenu = 1;
submenu = 1;
}
}
if(menu == 2)
{
lcd.setCursor(0,0);
lcd.print("LCD ");
lcd.setCursor(0,1);
lcd.print("PRESS START");
}
if(menu == 3)
{
lcd.setCursor(0,0);
lcd.print("RESET ");
lcd.setCursor(0,1);
lcd.print("PRESS START");
}
}
void mainsubmenu()
{
if(submenu == 1)
{
lcd.setCursor(0,0);
lcd.print("LED ");
lcd.setCursor(0,1);
lcd.print("PRESS BUTTON ");
}
}