1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162#define BLINKER_WIFI#include <Blinker.h>char auth[] = "";char ssid[] = "";char pswd[] = "";// 新建组件对象BlinkerButton Button1("btn-abc");BlinkerNumber Number1("num-abc");BlinkerButton led2("btn-led2");int counter = 0;// 按下按键即会执行该函数void button1_callback(const String & state){ BLINKER_LOG("get button state: ", state); digitalWrite(12, !digitalRead(12));}void led2_callback(const String & state){ BLINKER_LOG("get button state: ", state); digitalWrite(13, !digitalRead(13));}// 如果未绑定的组件被触发,则会执行其中内容void dataRead(const String & data){ BLINKER_LOG("Blinker readString: ", data); counter++; Number1.print(counter);}void setup(){ // 初始化串口 Serial.begin(115200); BLINKER_DEBUG.stream(Serial); BLINKER_DEBUG.debugAll(); // 初始化有LED的IO pinMode(12, OUTPUT); digitalWrite(12, HIGH); pinMode(13, OUTPUT); digitalWrite(13, HIGH); // 初始化blinker Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); led2.attach(led2_callback); Button1.attach(button1_callback);}void loop() { Blinker.run();}