小爱同学实现电脑语音开关机
本帖最后由 haijun523 于 2020-12-25 08:41 编辑#define BLINKER_MIOT_OUTLET
#define BLINKER_ALIGENIE_OUTLET
#define BLINKER_DUEROS_OUTLET
#include <Blinker.h>
char auth[] = "abdcefg";//设备key
char ssid[] = "abcd";//路由器wifi ssid
char pswd[] = "abcd";//路由器wifi 密码
BlinkerButton Button1("btn-abc"); //定义按钮键名
bool oState = false;
void button1_callback(const String & state)
{
BLINKER_LOG("get button state: ", state);
digitalWrite(0,LOW);
Blinker.delay(200); //点灯app内控制按键触发
digitalWrite(0, HIGH);
}
void miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(0, LOW);
Blinker.delay(200); //小爱同学控制开命令 此处修改为点动模式,适合按钮操作,
digitalWrite(0, HIGH);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
oState = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(0,LOW);
Blinker.delay(200); //小爱同学控制关命令 此处修改为点动模式,适合按钮操作
digitalWrite(0, HIGH);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
oState = false;
}
}
void aligeniePowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(0, LOW);
Blinker.delay(200); //小爱同学控制开命令 此处修改为点动模式,适合按钮操作,
digitalWrite(0, HIGH);
BlinkerAliGenie.powerState("on");
BlinkerAliGenie.print();
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(0,LOW);
Blinker.delay(200); //小爱同学控制关命令 此处修改为点动模式,适合按钮操作
digitalWrite(0, HIGH);
BlinkerAliGenie.powerState("off");
BlinkerAliGenie.print();
oState = false;
}
}
void duerPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(0, LOW);
Blinker.delay(200); //小爱同学控制开命令 此处修改为点动模式,适合按钮操作,
digitalWrite(0, HIGH);
BlinkerDuerOS.powerState("on");
BlinkerDuerOS.print();
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(0,LOW);
Blinker.delay(200); //小爱同学控制关命令 此处修改为点动模式,适合按钮操作
digitalWrite(0, HIGH);
BlinkerDuerOS.powerState("off");
BlinkerDuerOS.print();
oState = false;
}
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(0, OUTPUT); //定义io口为输出
digitalWrite(0, HIGH); //定义io默认为高电平
Blinker.begin(auth,ssid, pswd);
BlinkerDuerOS.attachPowerState(duerPowerState);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerAliGenie.attachPowerState(aligeniePowerState);
Button1.attach(button1_callback);
}
void loop()
{
Blinker.run();
}https://v.youku.com/v_show/id_XNTAyNDc5NTUyOA==.htmlhttps://v.youku.com/v_show/id_XNTAyNDc5NDQ3Mg==.html
能不能研究一下开关机状态反馈 报错
In file included from C:\Users\Administrator\Desktop\sketch_feb25a\sketch_feb25a.ino:4:0:
C:\Users\Administrator\Documents\Arduino\libraries\Blinker\src/Blinker.h:239:6: error: #error Please set a mode BLINKER_BLE/BLINKER_WIFI/BLINKER_MQTT ! Please check your mode setting.
#error Please set a mode BLINKER_BLE/BLINKER_WIFI/BLINKER_MQTT ! Please check your mode setting.
^
exit status 1
为开发板 Generic ESP8266 Module 编译时出错。
怎么解决啊 南阳|永党 发表于 2021-2-14 14:26
能不能研究一下开关机状态反馈
你研究出来了吗
页:
[1]