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-05-27 13:29:52

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Develop a Ben10 Omnitrix project using an Arduino */
	/* with a TFT round display and a push button */
	/* connected to pin D4. Utilize the EasyButton */
	/* library for button handling. Ensure the setup */
	/* initializes the button with INPUT_PULLUP mode. */
/****** 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 handler function

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t TFTrounddisplay_PushButton_PIN_D4 = 4;

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

void onPressed(void)
{
  Serial.println("Button pressed");
}

void setup(void)
{
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println();
  Serial.println(">>> EasyButton pressed example <<<");

  pinMode(TFTrounddisplay_PushButton_PIN_D4, INPUT_PULLUP);  // Set the button pin as INPUT_PULLUP
  button.begin();  // Initialize the button
  button.onPressed(onPressed);  // Attach the onPressed handler
}

void loop(void)
{
  // put your main code here, to run repeatedly:
  button.read();  // Read the button state
}

/* END CODE */