CCCPaste

Button Setup rev_02

/********* 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 Setup
	- Source Code compiled for: Arduino Uno
	- Source Code created on: 2024-01-24 20:31:49

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* if button is pressed so print hello on serial */
	/* monitor */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include  // include EasyButton library

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t BUTTON_PIN = 2; // define button pin

/****** DEFINITION OF LIBRARY CLASS INSTANCES*****/
EasyButton button(BUTTON_PIN); // create EasyButton object with button pin

// button pressed event handler
void onPressed()
{
  Serial.println("Hello"); // print "Hello" on the serial monitor
}

void setup(void)
{
  // initialize the button pin as INPUT_PULLUP
  pinMode(BUTTON_PIN, INPUT_PULLUP); 
  
  /****** SETTING UP EASY BUTTON AND EVENT HANDLING*****/
  button.begin();
  button.onPressed(onPressed);
}

void loop(void)
{
  button.read();

  // put your code here to run repeatedly
}