CCCPaste

Button Input rev_186

/********* 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 Input
	- Source Code compiled for: Arduino Nano ESP32
	- Source Code created on: 2024-01-14 12:25:28

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* do nothing */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include 

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

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t button_PushButton_PIN_D2 = 2;
const uint8_t digitalinput_PIN_D3 = 3;
const uint8_t diginputwithpullup_PIN_D4 = 4;
const uint8_t diginputwithpulldown_PIN_D5 = 5;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
EasyButton button_PushButton(button_PushButton_PIN_D2);
EasyButton digitalinput(digitalinput_PIN_D3);
EasyButton diginputwithpullup(diginputwithpullup_PIN_D4);
EasyButton diginputwithpulldown(diginputwithpulldown_PIN_D5);

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

    pinMode(button_PushButton_PIN_D2, INPUT_PULLUP);
    pinMode(digitalinput_PIN_D3, INPUT);
    pinMode(diginputwithpullup_PIN_D4, INPUT_PULLUP);
    pinMode(diginputwithpulldown_PIN_D5, INPUT_PULLDOWN);

    button_PushButton.begin();
    digitalinput.begin();
    diginputwithpullup.begin();
    diginputwithpulldown.begin();
}

void loop(void)
{
    // put your main code here, to run repeatedly:

    button_PushButton.read();
    digitalinput.read();
    diginputwithpullup.read();
    diginputwithpulldown.read();

    // Add your code logic for handling button events
    if (button_PushButton.wasPressed()) {
        // Button_PushButton was pressed
    }

    if (digitalinput.wasReleased()) {
        // digitalinput was released
    }

    if (diginputwithpullup.pressedFor(1000)) {
        // diginputwithpullup was pressed for 1 second
    }

    if (diginputwithpulldown.releasedFor(500)) {
        // diginputwithpulldown was released for 500 milliseconds
    }
}