Advertisement
pleasedontcode

"Button LCD" rev_07

Jun 6th, 2024
358
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: "Button LCD"
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-06-07 04:08:28
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* lcd display i2c  20x4  button pin11 UP LOW menu up */
  21.     /* button pin10 UP LOW menu enter  button pin12UP LOW */
  22.     /* menu down  Temperatur  submenu   MaxTemp */
  23.     /* subsubmenu  MinTeamp subsubmenu  Durchfluss(Flow) */
  24.     /* submenu   MaxFlow subsubmenu  MinFlow subsubmenu */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /****** DEFINITION OF LIBRARIES *****/
  28. #include <EasyButton.h>  //https://github.com/evert-arias/EasyButton
  29. #include <LiquidCrystal_I2C.h>  //https://github.com/marcoschwartz/LiquidCrystal_I2C
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34.  
  35. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  36. const uint8_t UP_BUTTON_PushButton_PIN_D11 = 11;
  37. const uint8_t DOWN_BUTTON_PushButton_PIN_D12 = 12;
  38. const uint8_t ENTER_BUTTON_PushButton_PIN_D10 = 10;
  39.  
  40. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  41. EasyButton buttonUp(UP_BUTTON_PushButton_PIN_D11);  // Initialize EasyButton for UP button
  42. EasyButton buttonDown(DOWN_BUTTON_PushButton_PIN_D12);  // Initialize EasyButton for DOWN button
  43. EasyButton buttonEnter(ENTER_BUTTON_PushButton_PIN_D10);  // Initialize EasyButton for ENTER button
  44.  
  45. LiquidCrystal_I2C lcd(0x27, 20, 4);  // Initialize LiquidCrystal_I2C with I2C address 0x27 and a 20x4 LCD
  46.  
  47. /****** CALLBACK FUNCTIONS FOR BUTTONS *****/
  48. void onButtonUpPressed() {
  49.   Serial.println("UP button pressed");
  50. }
  51.  
  52. void onButtonDownPressed() {
  53.   Serial.println("DOWN button pressed");
  54. }
  55.  
  56. void onButtonEnterPressed() {
  57.   Serial.println("ENTER button pressed");
  58. }
  59.  
  60. void setup(void) {
  61.   // put your setup code here, to run once:
  62.   Serial.begin(115200);
  63.  
  64.   // Initialize buttons
  65.   buttonUp.begin();
  66.   buttonDown.begin();
  67.   buttonEnter.begin();
  68.  
  69.   // Attach callback functions
  70.   buttonUp.onPressed(onButtonUpPressed);
  71.   buttonDown.onPressed(onButtonDownPressed);
  72.   buttonEnter.onPressed(onButtonEnterPressed);
  73.  
  74.   pinMode(UP_BUTTON_PushButton_PIN_D11, INPUT_PULLUP);
  75.   pinMode(DOWN_BUTTON_PushButton_PIN_D12, INPUT_PULLUP);
  76.   pinMode(ENTER_BUTTON_PushButton_PIN_D10, INPUT_PULLUP);
  77.  
  78.   // Initialize the LCD
  79.   lcd.init();
  80.   lcd.backlight();
  81.   lcd.setCursor(3, 0);
  82.   lcd.print("Hello, world!");
  83.   lcd.setCursor(2, 1);
  84.   lcd.print("Ywrobot Arduino!");
  85.   lcd.setCursor(0, 2);
  86.   lcd.print("Arduino LCM IIC 2004");
  87.   lcd.setCursor(2, 3);
  88.   lcd.print("Power By Ec-yuan!");
  89. }
  90.  
  91. void loop(void) {
  92.   // put your main code here, to run repeatedly:
  93.   buttonUp.read();
  94.   buttonDown.read();
  95.   buttonEnter.read();
  96. }
  97.  
  98. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement