#define BLINKER_PRINT Serial #define BLINKER_WIFI #include <Blinker.h> char auth[] = "c9876669831c"; //上一步中在app中获取到的Secret Key char ssid[] = "ChinaNet-Ks22"; //您的WiFi热点名称 char pswd[] = "12345678"; //您的WiFi密码 #include <Arduino.h> BlinkerButton button("btn"); void button1_callback(const String & state) { if (state == "on") { digitalWrite(LED_BUILTIN, LOW); button.text("已打开"); button.print("on"); }else { digitalWrite(LED_BUILTIN, HIGH); button.text("已关闭"); button.print("off"); } } void setup() { // write your initialization code here Serial.begin(115200); // 初始化有LED的IO pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, HIGH); //高电频默认关闭 // 初始化blinker Blinker.begin(auth, ssid, pswd); // Blinker.attachData(dataRead); button.attach(button1_callback); } void loop() { // write your code here Blinker.run(); }
[env:nodemcuv2] platform = espressif8266 board = nodemcuv2 framework = arduino lib_deps = Blinker@^0.3.10230510 monitor_speed = 115200
标签:板载,Blinker,ESP8266,digitalWrite,button,char,BUILTIN,LED From: https://www.cnblogs.com/lixingli/p/18363779