|
楼主 |
发表于 2020-3-9 14:09
|
显示全部楼层
功能是可以实现,不知道稳定把
#define BLINKER_WIFI
#include <Blinker.h>
BlinkerButton Button1("btc1");
BlinkerButton Button2("btc2");
BlinkerButton Button3("btc3");
BlinkerButton Button4("btc4");
BlinkerButton Button5("btc5");
BlinkerButton Button6("btc6");
BlinkerButton Button7("btc7");
BlinkerButton Button8("btc8");
BlinkerText Text1("text_1");
char i;
char auth[] = "******";
char ssid[] = "OrayBox-D5D6"; //caiyq52-改成自己的WIFI名称
char pswd[] = "123456789"; //caiyq52-改成自己的WIFI密码
bool oState[8] = { false }; //设置8路开关控制
void dataRead(const String & data) // 如果未绑定的组件被触发,则会执行其中内容
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
}
void button1_callback(const String & state) //点灯app内控制按键触发
{
BLINKER_LOG("get button state: ", state);
digitalWrite(D0, !digitalRead(D0));
}
void button2_callback(const String & state) //点灯app内控制按键触发
{
BLINKER_LOG("get button state: ", state);
digitalWrite(D1, !digitalRead(D1));
}
void button3_callback(const String & state) //点灯app内控制按键触发
{
BLINKER_LOG("get button state: ", state);
digitalWrite(D2, !digitalRead(D2));
}
void button4_callback(const String & state) //点灯app内控制按键触发
{
BLINKER_LOG("get button state: ", state);
digitalWrite(D3, !digitalRead(D3));
}
void button5_callback(const String & state) //点灯app内控制按键触发
{
BLINKER_LOG("get button state: ", state);
digitalWrite(D4, !digitalRead(D4));
}
void button6_callback(const String & state) //点灯app内控制按键触发
{
BLINKER_LOG("get button state: ", state);
digitalWrite(D5, !digitalRead(D5));
}
void button7_callback(const String & state) //点灯app内控制按键触发
{
BLINKER_LOG("get button state: ", state);
digitalWrite(D6, !digitalRead(D6));
}
void button8_callback(const String & state) //点灯app内控制按键触发
{
BLINKER_LOG("get button state: ", state);
digitalWrite(D7, !digitalRead(D7));
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(D0, OUTPUT);
digitalWrite(D0, LOW);
pinMode(D1, OUTPUT);
digitalWrite(D1, LOW);
pinMode(D2, OUTPUT);
digitalWrite(D2, LOW);
pinMode(D3, OUTPUT);
digitalWrite(D3, LOW);
pinMode(D4, OUTPUT);
digitalWrite(D4, LOW);
pinMode(D5, OUTPUT);
digitalWrite(D5, LOW);
pinMode(D6, OUTPUT);
digitalWrite(D6, LOW);
pinMode(D7, OUTPUT);
digitalWrite(D7, LOW);
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
Button1.attach(button1_callback);
Button2.attach(button2_callback);
Button3.attach(button3_callback);
Button4.attach(button4_callback);
Button5.attach(button5_callback);
Button6.attach(button6_callback);
Button7.attach(button7_callback);
Button8.attach(button8_callback);
}
void loop()
{
Blinker.run();
}
|
|