#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();
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
python, equal to anything!