CCCPaste

Button Detection rev_01

/********* 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-08-05 16:26:36

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Develop a responsive LED chaser that changes modes */
	/* with a button press. Use the EasyButton library */
	/* for simplified button handling, ensuring the */
	/* button on pin D2 is set to INPUT_PULLUP for */
	/* optimal performance. */
/****** 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 changemodebutton_PushButton_PIN_D2 = 2;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
// Initialize the EasyButton object for the button connected to pin D2
EasyButton changemodebutton(changemodebutton_PushButton_PIN_D2);

/****** FUNCTION DEFINITIONS *****/
void setup(void)
{
	// Initialize serial communication for debugging
	Serial.begin(115200);
	
	// Set the button pin as INPUT_PULLUP for optimal performance
	pinMode(changemodebutton_PushButton_PIN_D2, INPUT_PULLUP);

	// Begin the EasyButton instance
	changemodebutton.begin();

	// Attach the onPressed event handler to the button
	changemodebutton.onPressed([]() {
		Serial.println("Change mode button pressed");
	});
}

void loop(void)
{
	// Read the state of the button
	changemodebutton.read();
}

/* END CODE */