#include <LiquidCrystal_I2C.h> // include LCD display
#define I2C_ADDR 0x27 // define LCD display 0x27
#define LCD_COLLUMS 16 // define LCD collums 16
#define LCD_LINES 2 // define LCD lines 2
/*
******************************************
******************************************
** Name: Liam dutot **
** Prog Name: lab test **
** Date: 09/26/2024 **
** Desc: display multiple menu **
** screens on lcd display **
** **
******************************************
******************************************
*/
LiquidCrystal_I2C lcd (I2C_ADDR, LCD_COLLUMS, LCD_LINES);
int redLed = 8; // set redLed pin
int menuButton = 2; // set butotn pin
const int menuButton = 0;
const int menuNumber = 0;
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor (0,1);
lcd.print("* MENU SYSTEM *");
delay(100);
pinMode(redLed, OUTPUT);
analogWrite(redLed, 255);
pinMode(menuButton, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(menuButton), menuOption, FALLING); // attach menu button
}
void loop() {
if (menuNumber == 1){ // if menu number = 1
lcd.setCursor (0,0); //set the cursor to position 0,0
lcd.print (" Main MENU "); //print main menu
}
else if (menuNumber == 2){ // if menu number = 2
lcd.setCursor (0,0); // set cursor to 0,0
lcd.print (" Start MENU "); // print Start MENU
}
else if (menuNumber == 3){ // if menu number = 3
lcd.setCursor(0,0);
lcd.print (" ply MENU ");
}
else if (menuNumber == 4){
lcd.setCursor (0,0);
lcd.print (" winner MENU ");
digitalWrite(redLed, HIGH);
delay (700);
digitalWrite(redLed, LOW);
}
else if (menuNumber == 5){
lcd.setCursor(0,0);
lcd.print (" game over");
}
} // end if
if (digitalRead(menuButton, HIGH)){
menuNumber ++ 1;
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@interrupts below@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//function: a menu machine
//name: menuOption
//input: integer
//returns: void()
//desc:
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void menuOption() {
if (menuNumber > 5){
menuNumber = 1;
}
}