Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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: "Button Initialization"
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-06-07 04:06:28
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* lcd display i2c 20x4 button pin11 UPLOW menu up */
- /* button pin10 UP LOW menu enter button pin12UP LOW */
- /* menu down Temperatur submenu MaxTemp */
- /* subsubmenu MinTeamp subsubmenu Durchfluss(Flow) */
- /* submenu MaxFlow subsubmenu MinFlow subsubmenu */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h> // https://github.com/evert-arias/EasyButton
- #include <LiquidCrystal_I2C.h> // https://github.com/marcoschwartz/LiquidCrystal_I2C
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void onUpButtonPressed();
- void onDownButtonPressed();
- void onEnterButtonPressed();
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t UP_BUTTON_PIN = 11;
- const uint8_t DOWN_BUTTON_PIN = 12;
- const uint8_t ENTER_BUTTON_PIN = 10;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- EasyButton upButton(UP_BUTTON_PIN); // Initialize EasyButton for UP button
- EasyButton downButton(DOWN_BUTTON_PIN); // Initialize EasyButton for DOWN button
- EasyButton enterButton(ENTER_BUTTON_PIN); // Initialize EasyButton for ENTER button
- // Initialize LiquidCrystal_I2C object with I2C address 0x27, 20 columns, and 4 rows
- LiquidCrystal_I2C lcd(0x27, 20, 4);
- void setup(void) {
- // put your setup code here, to run once:
- Serial.begin(115200);
- // Initialize buttons
- upButton.begin();
- downButton.begin();
- enterButton.begin();
- // Attach callbacks
- upButton.onPressed(onUpButtonPressed);
- downButton.onPressed(onDownButtonPressed);
- enterButton.onPressed(onEnterButtonPressed);
- // Set pin modes
- pinMode(UP_BUTTON_PIN, INPUT_PULLUP);
- pinMode(DOWN_BUTTON_PIN, INPUT_PULLUP);
- pinMode(ENTER_BUTTON_PIN, INPUT_PULLUP);
- // Initialize the LCD
- lcd.init();
- lcd.backlight();
- lcd.setCursor(3, 0);
- lcd.print("Hello, world!");
- lcd.setCursor(2, 1);
- lcd.print("Ywrobot Arduino!");
- lcd.setCursor(0, 2);
- lcd.print("Arduino LCM IIC 2004");
- lcd.setCursor(2, 3);
- lcd.print("Power By Ec-yuan!");
- }
- void loop(void) {
- // put your main code here, to run repeatedly:
- upButton.read();
- downButton.read();
- enterButton.read();
- }
- void onUpButtonPressed() {
- Serial.println("Up button pressed");
- }
- void onDownButtonPressed() {
- Serial.println("Down button pressed");
- }
- void onEnterButtonPressed() {
- Serial.println("Enter button pressed");
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement