Skip to content

Commit

Permalink
update Button example codes
Browse files Browse the repository at this point in the history
  • Loading branch information
i3water committed May 9, 2018
1 parent c51d1d9 commit 4cf545e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
17 changes: 10 additions & 7 deletions examples/Blinker_Button/Button_BLE/Button_BLE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define BLINKER_BLE

#define BUTTON_1 "ButtonKey"
#define TAP_EXAMPLE

#include <Blinker.h>

Expand Down Expand Up @@ -30,14 +31,16 @@ void loop()
Blinker.print("millis", BlinkerTime);
}

#if defined(TAP_EXAMPLE)
if (Blinker.button(BUTTON_1)) {
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
} // simple tap

// if (Blinker.button(BUTTON_1)) {
// digitalWrite(LED_BUILTIN, LOW);
// }
// else {
// digitalWrite(LED_BUILTIN, HIGH);
// } //long press
#else
if (Blinker.button(BUTTON_1)) {
digitalWrite(LED_BUILTIN, LOW);
}
else {
digitalWrite(LED_BUILTIN, HIGH);
} //long press
#endif
}
19 changes: 11 additions & 8 deletions examples/Blinker_Button/Button_WiFi/Button_WiFi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define BLINKER_WIFI

#define BUTTON_1 "ButtonKey"
#define TAP_EXAMPLE

#include <Blinker.h>

Expand Down Expand Up @@ -32,15 +33,17 @@ void loop()
Blinker.print(BlinkerTime);
Blinker.print("millis", BlinkerTime);
}


#if defined(TAP_EXAMPLE)
if (Blinker.button(BUTTON_1)) {
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
} // simple tap

// if (Blinker.button(BUTTON_1)) {
// digitalWrite(LED_BUILTIN, LOW);
// }
// else {
// digitalWrite(LED_BUILTIN, HIGH);
// } //long press
#else
if (Blinker.button(BUTTON_1)) {
digitalWrite(LED_BUILTIN, LOW);
}
else {
digitalWrite(LED_BUILTIN, HIGH);
} //long press
#endif
}

0 comments on commit 4cf545e

Please sign in to comment.