为什么点击APP按键后继电器接通,但app就显示离线,等按键设定的时间执行完又恢复在线,是代码有问题吗??
- #define BLINKER_WIFI
- #include <Blinker.h>
- char auth[] = ""; //设备key
- char ssid[] = ""; //路由器wifi ssid
- char pswd[] = ""; //路由器wifi 密码
- BlinkerButton Button1("btn-on"); //定义按钮键名
- int counter = 0;
- void button1_callback(const String & state) //点灯app内控制按键触发接通20秒
- {
- BLINKER_LOG("get button state: ", state);
- digitalWrite(0,HIGH);
- delay(20000);
- digitalWrite(0, LOW);
- }
- void setup()
- {
- Serial.begin(115200);
- BLINKER_DEBUG.stream(Serial);
-
- pinMode(0, OUTPUT); //定义io口为输出
- digitalWrite(0, LOW); //定义io默认为低电平
- Blinker.begin(auth, ssid, pswd);
- Button1.attach(button1_callback);
- }
- void loop()
- {
- Blinker.run();
- }
复制代码
|