本帖最后由 鑫期天 于 2018-9-2 22:38 编辑
one button库与blinker不兼容?
我试了好几次了,怎么也不行,不知道哪不对!!!
//-----------------------------------------
#define BLINKER_PRINT Serial
#define BLINKER_WIFI
#include <Blinker.h>
#include "OneButton.h"
char ssid[] = "**********";
char pswd[] = "*********";
OneButton button(D3, true);
BlinkerButton Button1("btn-abc");
BlinkerNumber Number1("num-abc");
int counter = 0;
void button1_callback(const String & state) {
BLINKER_LOG2("get button state: ", state);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
void setup() {
Serial.begin(115200);
pinMode(D4, OUTPUT); // sets the digital pin as output
button.attachDoubleClick(doubleclick);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
Blinker.begin(ssid, pswd);
Button1.attach(button1_callback);
}
void loop() {
button.tick();
Blinker.run();
if (Blinker.available()) {
BLINKER_LOG2("Blinker.readString(): ", Blinker.readString());
counter++;
Number1.print(counter);
}
delay(10);
}
void doubleclick() {
static int m = LOW;
m = !m;
digitalWrite(D4, m);
}
/-------------------------------------------------------------------------- |