|
是全复制你的例程呢,不知道怎么不成功
#define BLINKER_WIFI
#include <Blinker.h>
char auth[] = "Your Device Secret Key";
char ssid[] = "Your WiFi network SSID or name";
char pswd[] = "Your WiFi network WPA password or WEP key";
// 新建组件对象
BlinkerButton Button1("btn-abc");
// 按下按键即会执行该函数
void button1_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
}
// 心跳包函数
void heartbeat() {
Button1.icon("fas fa-lightbulb");
Button1.color("#fddb00");
Button1.text("关灯","打开啦");
Button1.print("on");
}
void setup() {
// 初始化串口
Serial.begin(115200);
// 初始化有LED的IO
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
// 初始化blinker
Blinker.begin(auth, ssid, pswd);
Button1.attach(button1_callback);
//注册一个心跳包
Blinker.attachHeartbeat(heartbeat);
}
void loop() {
Blinker.run();
} |
|