大神帮我看下为什么不运行
本帖最后由 桥边等 于 2019-6-8 21:50 编辑代码如下 为什么 如果我把中断 //attachInterrupt(D1,buttonTick, RISING);前面//去掉,整个程序不能运行!#define BLINKER_WIFI
#define BLINKER_ALIGENIE_LIGHT
#include <Blinker.h>
char auth[] = "fb843f67ea98";
char ssid[] = "ChinaUnicom";
char pswd[] = "3ezb-mknc-49w5";
boolean pushButton,outButton;
// 新建组件对象
BlinkerButton Button1("btn-abc");
BlinkerButton Button2("btn-abd");
// 按下按键即会执行该函数
void button1_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
if (state=="on") {
digitalWrite(D2, LOW);
// 反馈开关状态
Button1.print("on");
} else if(state=="off"){
digitalWrite(D2, HIGH);
// 反馈开关状态
Button1.print("off");
}
}
void button2_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
if (state=="on") {
digitalWrite(D2, LOW);
// 反馈开关状态
Button2.print("on");
} else if(state=="off"){
digitalWrite(D2, HIGH);
// 反馈开关状态
Button2.print("off");
}
}
void aligeniePowerSate(const String & state) //台灯开关处理
{
Serial.print(state);
if (state == BLINKER_CMD_ON) {
button1_callback("on");
BlinkerAliGenie.powerState("on");
BlinkerAliGenie.print();
}
else if (state == BLINKER_CMD_OFF) {
button1_callback("off");
BlinkerAliGenie.powerState("off");
BlinkerAliGenie.print();
}
}
void setup() {
// 初始化串口
Serial.begin(115200);
// 初始化有LED的IO
pinMode(D2, OUTPUT);
digitalWrite(D2, HIGH);
// 初始化blinker
Blinker.begin(auth, ssid, pswd);
Button1.attach(button1_callback);
Button2.attach(button2_callback);
BlinkerAliGenie.attachPowerState(aligeniePowerSate);
//attachInterrupt(D1,buttonTick, RISING);
}
void loop() {
Blinker.run();
}
void buttonTick() {
pushButton = digitalRead(D1); //读取引脚2电平状态并将其赋值给布尔变量
outButton = digitalRead(D2);
if (pushButton){
delay (40);
while(pushButton){
pushButton = digitalRead(D1);
delay (40);
}
outButton=!outButton;
if (outButton){
button1_callback("on");
Button1.print("on");
}
else if (!outButton) {
button1_callback("off");
Button1.print("off");
}
}
}
1.描述清楚问题
2.debug调试
https://www.arduino.cn/thread-84332-1-1.html 主板是 UNO 么?D0/D1 根本就是串口的数据线,干啥非要绑定中断? t3486784401 发表于 2019-6-8 22:35
主板是 UNO 么?D0/D1 根本就是串口的数据线,干啥非要绑定中断?
用的是ESP8266,我D4 D6都试了,开机闪蓝灯 奈何col 发表于 2019-6-8 22:31
1.描述清楚问题
2.debug调试
__ __ __
/\ \ /\ \ __ /\ \ v0.3.0
\ \ \___ \ \ \/\_\ ___\ \ \/'\ __ _ __
\ \ '__`\\ \ \ \/\ \ /' _ `\ \ , < /'__`\/\`'__\
\ \ \L\ \\ \ \_\ \ \/\ \/\ \ \ \\`\ /\__/\ \ \./
\ \_,__/ \ \__\\ \_\ \_\ \_\ \_\ \_\ \____\\ \_\
\/___/ \/__/ \/_/\/_/\/_/\/_/\/_/\/____/ \/_/
To better use blinker with your IoT project!
Download latest blinker library here!
=> https://github.com/blinker-iot/blinker-library
_aliType: &aliType=light
_duerType:
_authKey: fb843f67ea98
Connecting to ChinaUnicom
ESP8266_MQTT initialized...
===========================================================
================== Blinker Timer loaded! ==================
Warning!EEPROM address 1536-2431 is used for Blinker Timer!
============= DON'T USE THESE EEPROM ADDRESS! =============
===========================================================
countdown state: false
_cdRunState: 0
_totalTime: 0
_runTime: 0
_action:
loop state: false
_lpRunState: 0
_times: 0
_tri_times: 0
_time1: 0
_action1:
_time2: 0
_action2:
_lpData: 0
ISR not in IRAM!
奈何col 发表于 2019-6-8 22:31
1.描述清楚问题
2.debug调试
具体表现为设备闪蓝灯,设备不在线 桥边等 发表于 2019-6-8 22:50
具体表现为设备闪蓝灯,设备不在线
https://www.arduino.cn/thread-83658-1-1.html
1.学会清楚的描述问题
2.库版本太老了,请按照文档重新安装
3.你的程序太多问题了,我都不想说了,但我精简你的程序后测试,是可以正常运行的
页:
[1]