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 Pro Mini 3.3V
	- Source Code created on: 2024-06-30 13:33:39

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Develop a system to detect button presses using an */
	/* EasyButton library. The button is connected to */
	/* digital pin D2. The system should initialize the */
	/* button in the setup() function and continuously */
	/* check for button presses in the loop() function. */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include   //https://github.com/evert-arias/EasyButton

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void onPressed(void);  // Prototype for the button press callback function

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t go_PushButton_PIN_D2 = 2;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
EasyButton button(go_PushButton_PIN_D2);  // Initialize EasyButton with the pin number

/****** CALLBACK FUNCTION *****/
void onPressed()
{
  Serial.println("Button 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 */