/********* 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 Handler - Source Code NOT compiled for: Arduino Uno - Source Code created on: 2024-09-22 23:32:47 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Implemente um sistema de controle de botões usando */ /* a biblioteca EasyButton para gerenciar três botões */ /* de pressão nos pinos digitais D2, D3 e D4, */ /* garantindo um tratamento de entrada confiável para */ /* interações do usuário no projeto Arduino. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include //https://github.com/evert-arias/EasyButton /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t atirador_PushButton_PIN_D2 = 2; const uint8_t atirador_PushButton_PIN_D3 = 3; const uint8_t atirador_PushButton_PIN_D4 = 4; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ // Instantiate EasyButton objects for each button EasyButton button1(atirador_PushButton_PIN_D2); EasyButton button2(atirador_PushButton_PIN_D3); EasyButton button3(atirador_PushButton_PIN_D4); // Function prototypes for button press events void onButton1Pressed(); void onButton2Pressed(); void onButton3Pressed(); /****** SETUP FUNCTION *****/ void setup(void) { // Start the serial communication Serial.begin(115200); // Print a message to the Serial Monitor Serial.println(); Serial.println(">>> EasyButton multiple buttons example <<<"); // Initialize buttons button1.begin(); button2.begin(); button3.begin(); // Attach event handlers for button presses button1.onPressed(onButton1Pressed); button2.onPressed(onButton2Pressed); button3.onPressed(onButton3Pressed); } /****** LOOP FUNCTION *****/ void loop(void) { // Read the state of each button button1.read(); button2.read(); button3.read(); } /****** BUTTON PRESS HANDLERS *****/ // Function to handle button 1 press void onButton1Pressed() { Serial.println("Button 1 pressed"); } // Function to handle button 2 press void onButton2Pressed() { Serial.println("Button 2 pressed"); } // Function to handle button 3 press void onButton3Pressed() { Serial.println("Button 3 pressed"); } /* END CODE */