/********* 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 Callbacks
- Source Code compiled for: Arduino Uno
- Source Code created on: 2024-03-19 18:22:44
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* The system shall detect button press events on */
/* pins D2 and D3 using the EasyButton library. */
/****** SYSTEM REQUIREMENT 2 *****/
/* The system shall detect button press events on */
/* pins D2 and D3 using the EasyButton library. */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include
/****** FUNCTION PROTOTYPES *****/
void setup();
void loop();
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t BUTTON_ONE_PIN = 2;
const uint8_t BUTTON_TWO_PIN = 3;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
EasyButton button1(BUTTON_ONE_PIN);
EasyButton button2(BUTTON_TWO_PIN);
void onButton1Pressed()
{
// Callback function when button1 is pressed
Serial.println("Button1 pressed");
}
void onButton2Pressed()
{
// Callback function when button2 is pressed
Serial.println("Button2 pressed");
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
// Initialize the buttons
button1.begin();
button2.begin();
// Assign the callback functions to the buttons
button1.onPressed(onButton1Pressed);
button2.onPressed(onButton2Pressed);
}
void loop()
{
// put your main code here, to run repeatedly:
button1.read();
button2.read();
}