#include <LiquidCrystal_I2C.h>
// define LED display
#define I2C_ADDR 0x27
#define LCD_COLUMNS 16
#define LCD_LINES 2
// create led display with defined parameters
LiquidCrystal_I2C lcd(I2C_ADDR,LCD_COLUMNS, LCD_LINES);
// define LED pins
int GreLED = 9;
int RedLED = 8;
// define button pins
int RedButton = 3;
int GreButton = 2;
// other variables
int theVariable = 0;
void setup() {
// put your setup code here, to run once:
// initialize LED Display
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(" *MY MENU* ");
delay(1000);
pinMode(GreLED, OUTPUT);
pinMode(RedLED, OUTPUT);
pinMode(GreButton, INPUT_PULLUP);
pinMode(RedButton, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(GreButton), menuUp, FALLING);
attachInterrupt(digitalPinToInterrupt(RedButton), menuDown, RISING);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(RedButton) == 0) {
theVariable = 1;
} else if (digitalRead(GreButton) == 1) {
theVariable = 2;
}
if (theVariable = 1){
menuDown;
} else if(theVariable = 2){
menuUp;
}
}
void menuUp(){
digitalWrite(GreLED, HIGH);
digitalWrite(RedLED, LOW);
//lcd.setCursor(1,0);
//lcd.print("* START TOO *");
theVariable = 0;
}
void menuDown(){
digitalWrite(RedLED, HIGH);
digitalWrite(GreLED,LOW);
//lcd.setCursor(1,0);
//lcd.print("* MAIN Won *");
theVariable = 0;
}