#include <LiquidCrystal.h>

// Initialize the LCD object
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Define the button pin
const int buttonPin = 7;

// Define the dinner options
const char* dinnerOptions[] = {"Pasta", "Pizza", "Quesadilla", "Tacos", "Sushi", "Dosa", "Casserole"};
const int numOptions = 7;

void setup() {
  // Set up the LCD's number of columns and rows
  lcd.begin(16, 2);

  // Print a message to the LCD
  lcd.setCursor(0, 0);
  lcd.print("What's for");
  lcd.setCursor(0, 1);
  lcd.print("Dinner?");
  
  // Set button pin as input with internal pull-up resistor
  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {

  // Check if the button is pressed
  if (digitalRead(buttonPin) == LOW) {
    // Wait for the button to be released
    while (digitalRead(buttonPin) == LOW);
    
    // Generate a random number between 0 and numOptions - 1
    int randomIndex = random(0, numOptions);

    // Clear the LCD
    lcd.clear();

    // Display the selected dinner option
    lcd.setCursor(0, 0);
    lcd.print("Dinner:");
    lcd.setCursor(0, 1);
    lcd.print(dinnerOptions[randomIndex]);

    // Wait for a short period to avoid multiple readings
    delay(7000);
    lcd.clear ();
    lcd.setCursor(0, 0);
    lcd.print("What's for");
    lcd.setCursor(0, 1);
    lcd.print("Dinner?");
  }
}