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: ESP32 DevKit V1
	- Source Code created on: 2024-10-05 10:42:29

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* The system shall utilize the EasyButton library to */
	/* manage button presses on a digital input pin (D4) */
	/* with INPUT_PULLUP configuration for reliable state */
	/* detection. */
/****** 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 bbb_PushButton_PIN_D4 = 4;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
// Initialize the EasyButton object for the defined pin with INPUT_PULLUP configuration
EasyButton button(bbb_PushButton_PIN_D4, 35, true, true); // debounce_time = 35ms, pullup_enable = true, active_low = true

/****** FUNCTION DEFINITIONS *****/
// Function to be called when the button is pressed
void onButtonPressed() {
    Serial.println("Button pressed");
}

void setup(void)
{
    // Start serial communication for debugging
    Serial.begin(115200);
    
    // Print a message to indicate setup has started
    Serial.println();
    Serial.println(">>> EasyButton example <<<");

    // Initialize the button
    button.begin();
    
    // Attach the onPressed function to the button
    button.onPressed(onButtonPressed);
}

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

/* END CODE */