/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: Menu_Selection
- Source Code compiled for: Arduino Uno
- Source Code created on: 2023-11-22 05:54:12
- Source Code generated by: Gavin
********* Pleasedontcode.com **********/
/****** DEFINITION OF LIBRARIES *****/
#include
/****** SYSTEM REQUIREMENT 1 *****/
/* when start is pushed it needs to bring up a menu */
/* with 3 selections. 1.date and Time setting, 2. */
/* Customer name and 3. Label Format. 0 . Back to */
/* main menu , 99 Exit */
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void showMenu(void);
void processSelection(int selection);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t Start_PIN_D2 = 2;
void setup(void)
{
// Initialize serial communication
Serial.begin(9600);
// Set the pin mode for start button
pinMode(Start_PIN_D2, INPUT);
}
void loop(void)
{
// Read the start button state
int startButtonState = digitalRead(Start_PIN_D2);
if (startButtonState == HIGH)
{
showMenu(); // Display the menu when the start button is pressed
while (startButtonState == HIGH)
{
startButtonState = digitalRead(Start_PIN_D2); // Continue reading the start button state to see if it's still pressed
delay(100);
}
}
}
void showMenu()
{
// Display the menu options
Serial.println("Menu Options:");
Serial.println("1. Date and Time Setting");
Serial.println("2. Customer Name");
Serial.println("3. Label Format");
Serial.println("0. Back to Main Menu");
Serial.println("99. Exit");
// Wait for user input
while (Serial.available() == 0)
{
delay(100);
}
// Process the user selection
int selection = Serial.parseInt();
processSelection(selection);
}
void processSelection(int selection)
{
switch (selection)
{
case 1:
// Date and Time Setting functionality
Serial.println("Setting Date and Time...");
// Add your code here to set date and time
break;
case 2:
// Customer Name functionality
Serial.println("Editing Customer Name...");
// Add your code here to edit customer name
break;
case 3:
// Label Format functionality
Serial.println("Selecting Label Format...");
// Add your code here to select label format
break;
case 0:
// Back to Main Menu functionality
Serial.println("Going back to Main Menu...");
// Add your code here to go back to main menu
break;
case 99:
// Exit functionality
Serial.println("Exiting...");
// Add your code here to exit the program
break;
default:
// Invalid selection
Serial.println("Invalid selection!");
break;
}
}