Advertisement
pleasedontcode

**LCD Navigation** rev_01

Nov 27th, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **LCD Navigation**
  13.     - Source Code NOT compiled for: ESP8266 NodeMCU V1.0
  14.     - Source Code created on: 2024-11-27 14:32:50
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* LCD Menu with Options */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <LiquidCrystal.h>
  27. #include <Wire.h>
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32. void displayMenu();
  33. void handleMenuSelection(int selection);
  34.  
  35. /****** GLOBAL VARIABLES *****/
  36. LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initialize the LCD with the appropriate pins
  37. int menuOption = 0; // Variable to keep track of the current menu option
  38.  
  39. void setup(void)
  40. {
  41.     // Initialize the LCD
  42.     lcd.begin(16, 2); // Set up the LCD's number of columns and rows
  43.     lcd.clear(); // Clear the LCD screen
  44.     displayMenu(); // Display the menu options
  45. }
  46.  
  47. void loop(void)
  48. {
  49.     // Here you can implement code to change the menuOption variable
  50.     // For example, using buttons to navigate through the menu
  51.     // This is a placeholder for menu selection handling
  52.     if (menuOption == 1) {
  53.         handleMenuSelection(menuOption);
  54.     }
  55.     // Add more conditions for other menu options as needed
  56. }
  57.  
  58. /****** FUNCTION IMPLEMENTATIONS *****/
  59. void displayMenu() {
  60.     lcd.clear(); // Clear the LCD before displaying the menu
  61.     lcd.setCursor(0, 0); // Set cursor to the first line
  62.     lcd.print("1. Option 1"); // Display first menu option
  63.     lcd.setCursor(0, 1); // Set cursor to the second line
  64.     lcd.print("2. Option 2"); // Display second menu option
  65. }
  66.  
  67. void handleMenuSelection(int selection) {
  68.     lcd.clear(); // Clear the LCD for the selected option
  69.     lcd.setCursor(0, 0); // Set cursor to the first line
  70.     if (selection == 1) {
  71.         lcd.print("You selected 1"); // Handle Option 1
  72.     } else if (selection == 2) {
  73.         lcd.print("You selected 2"); // Handle Option 2
  74.     }
  75. }
  76.  
  77. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement