feat: светодиод IO12 — горит во время debounce после нажатия кнопки

This commit is contained in:
Aleksei
2026-06-17 10:20:10 +00:00
parent beebb67fec
commit 5b8e0e8aaf
+13 -1
View File
@@ -11,6 +11,7 @@
#define BTN1_PIN 4
#define BTN2_PIN 2
#define LED_PIN 12
#define ETH_POWER_PIN 16
#define ETH_MDC_PIN 23
@@ -18,7 +19,7 @@
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
#define AP_SSID "Barrier-Setup"
#define FW_VERSION "1.3"
#define FW_VERSION "1.4"
#define AP_PASS "barrier123"
Preferences prefs;
@@ -283,6 +284,8 @@ void setup() {
Serial.begin(115200);
pinMode(BTN1_PIN, INPUT_PULLUP);
pinMode(BTN2_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
loadConfig();
@@ -325,11 +328,20 @@ void loop() {
if (digitalRead(BTN1_PIN) == LOW && now - lastPress1 > DEBOUNCE) {
lastPress1 = now;
digitalWrite(LED_PIN, HIGH);
Serial.println("Кнопка 1");
sendCommand(cfg_ip1);
}
// Гасим светодиод когда debounce прошёл
if (now - lastPress1 < DEBOUNCE || now - lastPress2 < DEBOUNCE) {
digitalWrite(LED_PIN, HIGH);
} else {
digitalWrite(LED_PIN, LOW);
}
if (digitalRead(BTN2_PIN) == LOW && now - lastPress2 > DEBOUNCE) {
lastPress2 = now;
digitalWrite(LED_PIN, HIGH);
Serial.println("Кнопка 2");
sendCommand(cfg_ip2);
}