/********* 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 Login - Source Code compiled for: Arduino Uno - Source Code created on: 2023-12-15 14:54:40 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* login screen for a Management applincation */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include #include /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t Login_PushButton_PIN_D2 = 2; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ EasyButton loginPushButton(Login_PushButton_PIN_D2); void setup(void) { // put your setup code here, to run once: loginPushButton.begin(); // Uncomment the following line if you want to enable the built-in pull-up resistor // loginPushButton.enablePullup(); // Uncomment the following line if you want to set a different debounce time // loginPushButton.setDebounceTime(50); } void loop(void) { // put your main code here, to run repeatedly: loginPushButton.read(); if (loginPushButton.isPressed()) { // Button is pressed // Add your code here } if (loginPushButton.isReleased()) { // Button is released // Add your code here } // Add your own logic for long press and duration checks // Example: static unsigned long pressStartTime = 0; static bool longPressTriggered = false; if (loginPushButton.isPressed()) { // Button is pressed if (!longPressTriggered) { // Start counting the press duration pressStartTime = millis(); } } else { // Button is released if (!longPressTriggered && (millis() - pressStartTime >= 1000)) { // Button was pressed for at least 1 second // Add your code here longPressTriggered = true; } } if (loginPushButton.isReleased()) { // Button is released if (longPressTriggered && (millis() - pressStartTime < 1000)) { // Button was released before 1 second // Add your code here longPressTriggered = false; } } }