CCCPaste

Button Setup 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 Setup
	- Source Code compiled for: Arduino Uno
	- Source Code created on: 2024-01-17 06:55:53

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* LED sensor */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include "EasyButton.h"

/****** SYSTEM REQUIREMENTS *****/

/****** SYSTEM REQUIREMENT 1 *****/
/* LED sensor */

/****** END SYSTEM REQUIREMENTS *****/

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

/***** DEFINITION OF DIGITAL INPUT PINS *****/

const uint8_t START_PUSHBUTTON_PIN = 2; // Replace with the actual pin number

/****** DECLARATION OF OBJECTS AND VARIABLES *****/
EasyButton Start_PushButton(START_PUSHBUTTON_PIN);

void buttonPressed() {
  // Code for buttonPressed()
}

void sequenceElapsed() {
  // Code for sequenceElapsed()
}

void setup(void)
{
  // put your setup code here, to run once:

  pinMode(START_PUSHBUTTON_PIN, INPUT_PULLUP);

  Start_PushButton.begin();

  Start_PushButton.onPressed(buttonPressed);

  Start_PushButton.onPressedFor(500, sequenceElapsed);
}

void loop(void)
{
  // put your main code here, to run repeatedly:
  //
  // Example code provided below
  // Replace it with your own logic

  if (Start_PushButton.isPressed()) {
    // Button is currently pressed
    // Add your code here
  }

  if (Start_PushButton.isReleased()) {
    // Button is currently released
    // Add your code here
  }

  if (Start_PushButton.pressedFor(1000)) {
    // Button has been pressed for a duration of 1 second (1000ms)
    // Add your code here
  }

  if (Start_PushButton.wasPressed()) {
    // Button was pressed at the last read
    // Add your code here
  }

  if (Start_PushButton.wasReleased()) {
    // Button was released at the last read
    // Add your code here
  }

  if (Start_PushButton.releasedFor(2000)) {
    // Button has been released for a duration of 2 seconds (2000ms)
    // Add your code here
  }

  Start_PushButton.update();

}