/********* 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 Control
- Source Code NOT compiled for: Arduino Nano
- Source Code created on: 2024-04-25 11:41:27
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Ensure LED diode turns on for 50ms after pressing */
/* the EasyButton. It should turn off after 50ms, */
/* even if the button is still pressed. Allow */
/* reactivation only after a 2s delay. */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include
EasyButton button(Przycisk_PushButton_PIN_D2); // Initialize EasyButton with pin 2
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;
unsigned long reactivateDelay = 2000;
bool ledState = LOW;
bool buttonState = LOW;
void setup(void)
{
// put your setup code here, to run once:
pinMode(Przycisk_PushButton_PIN_D2, INPUT_PULLUP);
pinMode(Zawor_LED_PIN_D3, OUTPUT);
button.begin(); // Initialize EasyButton
}
void loop(void)
{
// put your main code here, to run repeatedly:
button.read(); // Read the state of the button
if (button.isPressed()) {
if (millis() - lastDebounceTime > debounceDelay) {
lastDebounceTime = millis();
ledState = HIGH;
digitalWrite(Zawor_LED_PIN_D3, ledState);
delay(50);
ledState = LOW;
digitalWrite(Zawor_LED_PIN_D3, ledState);
delay(reactivateDelay);
}
}
}
/* END CODE */