- #define BLINKER_BLE
- #include <Blinker.h>
- BlinkerButton Button1("btn-abc");
- BlinkerNumber Number1("num-abc");
- int counter = 0;
- void button1_callback(const String & state)
- {
- BLINKER_LOG("get button state: ", state);
- digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
- }
- void dataRead(const String & data)
- {
- BLINKER_LOG("Blinker readString: ", data);
- counter++;
- Number1.print(counter);
- }
- void setup()
- {
- Serial.begin(115200);
- BLINKER_DEBUG.stream(Serial);
-
- pinMode(LED_BUILTIN, OUTPUT);
- digitalWrite(LED_BUILTIN, LOW);
-
- Blinker.begin();
- Blinker.attachData(dataRead);
- }
- void loop()
- {
- Blinker.run();
- }
复制代码
|