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 Detection"
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-06-22 07:54:36
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Develop a flight management system using */
- /* EasyButton library to handle button inputs. The */
- /* system should initialize a push button on pin D2 */
- /* and manage its states to trigger specific flight */
- /* operations. */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void onPressed(); // Callback function for button press
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t pushbutton_PIN_D2 = 2;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- EasyButton button(pushbutton_PIN_D2); // Initialize EasyButton object
- void onPressed()
- {
- Serial.println("Button pressed"); // Print message when button is pressed
- }
- void setup(void)
- {
- // put your setup code here, to run once:
- Serial.begin(115200); // Initialize serial communication
- Serial.println();
- Serial.println(">>> EasyButton pressed example <<<");
- button.begin(); // Initialize the button
- button.onPressed(onPressed); // Attach the callback function
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- button.read(); // Read the button state
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement