/********* 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 Press" - Source Code NOT compiled for: Arduino Pro Mini 3.3V - Source Code created on: 2024-06-16 13:01:46 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Implement a system to detect button presses using */ /* EasyButton library. Utilize digital pins D2 and D3 */ /* as input pins for two push buttons. Ensure the */ /* system initializes pins in setup() and */ /* continuously checks button states in loop(). */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include //https://github.com/evert-arias/EasyButton /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void onButton1Pressed(void); void onButton2Pressed(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t XXMX_PushButton_PIN_D2 = 2; const uint8_t XXMX_PushButton_PIN_D3 = 3; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ EasyButton button1(XXMX_PushButton_PIN_D2); // Initialize EasyButton object for button1 EasyButton button2(XXMX_PushButton_PIN_D3); // Initialize EasyButton object for button2 void onButton1Pressed() { Serial.println("Button1 pressed"); } void onButton2Pressed() { Serial.println("Button2 pressed"); } void setup(void) { // Initialize serial communication Serial.begin(115200); Serial.println(); Serial.println(">>> EasyButton multiple buttons example <<<"); // Initialize buttons button1.begin(); // Initialize button1 button2.begin(); // Initialize button2 // Attach callback functions for button presses button1.onPressed(onButton1Pressed); // Attach callback for button1 button2.onPressed(onButton2Pressed); // Attach callback for button2 } void loop(void) { // Continuously check the state of the buttons button1.read(); // Read the state of button1 button2.read(); // Read the state of button2 } /* END CODE */