feat: светодиод IO12 — горит во время debounce после нажатия кнопки
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#define BTN1_PIN 4
|
#define BTN1_PIN 4
|
||||||
#define BTN2_PIN 2
|
#define BTN2_PIN 2
|
||||||
|
#define LED_PIN 12
|
||||||
|
|
||||||
#define ETH_POWER_PIN 16
|
#define ETH_POWER_PIN 16
|
||||||
#define ETH_MDC_PIN 23
|
#define ETH_MDC_PIN 23
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
|
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
|
||||||
|
|
||||||
#define AP_SSID "Barrier-Setup"
|
#define AP_SSID "Barrier-Setup"
|
||||||
#define FW_VERSION "1.3"
|
#define FW_VERSION "1.4"
|
||||||
#define AP_PASS "barrier123"
|
#define AP_PASS "barrier123"
|
||||||
|
|
||||||
Preferences prefs;
|
Preferences prefs;
|
||||||
@@ -283,6 +284,8 @@ void setup() {
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
pinMode(BTN1_PIN, INPUT_PULLUP);
|
pinMode(BTN1_PIN, INPUT_PULLUP);
|
||||||
pinMode(BTN2_PIN, INPUT_PULLUP);
|
pinMode(BTN2_PIN, INPUT_PULLUP);
|
||||||
|
pinMode(LED_PIN, OUTPUT);
|
||||||
|
digitalWrite(LED_PIN, LOW);
|
||||||
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
@@ -325,11 +328,20 @@ void loop() {
|
|||||||
|
|
||||||
if (digitalRead(BTN1_PIN) == LOW && now - lastPress1 > DEBOUNCE) {
|
if (digitalRead(BTN1_PIN) == LOW && now - lastPress1 > DEBOUNCE) {
|
||||||
lastPress1 = now;
|
lastPress1 = now;
|
||||||
|
digitalWrite(LED_PIN, HIGH);
|
||||||
Serial.println("Кнопка 1");
|
Serial.println("Кнопка 1");
|
||||||
sendCommand(cfg_ip1);
|
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) {
|
if (digitalRead(BTN2_PIN) == LOW && now - lastPress2 > DEBOUNCE) {
|
||||||
lastPress2 = now;
|
lastPress2 = now;
|
||||||
|
digitalWrite(LED_PIN, HIGH);
|
||||||
Serial.println("Кнопка 2");
|
Serial.println("Кнопка 2");
|
||||||
sendCommand(cfg_ip2);
|
sendCommand(cfg_ip2);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user