功能:在APP端设置了4个按键,按下每个按键端口输出不同的数组
问题:a,b,c,d四个按键对应输出A,B,C,D四个数组,但实际上按下b会输出AB两个数组的数,按下c会输出ABC三个数组的数,按下d会输出ABCD四个数组的数。求助。。。
代码:
#define BLINKER_WIFI
#include <Blinker.h>
#include <Arduino.h>
char DATA1[]={0x55,0xAA,0x11,0x02,0x01,0x10,0x24,0x02};
char DATA2[]={0x55,0xAA,0x11,0x02,0x01,0x20,0x34,0x32};
char DATA3[]={0x55,0xAA,0x22,0x02,0x01,0x10,0x35,0x31};
char DATA4[]={0x55,0xAA,0x22,0x02,0x01,0x20,0x45,0x01};
char auth[] = "5b05dc85109b";//Your Device Secret Key
char ssid[] = "keke";//Your WiFi network SSID or name
char pswd[] = "123456789";//Your WiFi network WPA password or WEP key
BlinkerButton Button1("btn-1l");
BlinkerButton Button2("btn-1r");
BlinkerButton Button3("btn-2l");
BlinkerButton Button4("btn-2r");
void Button1_callback(const String & state)
{
digitalWrite(5,HIGH);
Serial.print(DATA1);
Blinker.delay(300);
}
void Button2_callback(const String & state)
{
digitalWrite(5,HIGH);
Serial.print(DATA2);
Blinker.delay(300);
}
void Button3_callback(const String & state)
{
digitalWrite(5,HIGH);
Serial.print(DATA3);
Blinker.delay(300);
}
void Button4_callback(const String & state)
{
digitalWrite(5,HIGH);
Serial.print(DATA4);
Blinker.delay(300);
}
void setup() {
Serial.begin(14400);
pinMode(5,OUTPUT);
Blinker.begin(auth, ssid, pswd);
Button1.attach(Button1_callback);
Button2.attach(Button2_callback);
Button3.attach(Button3_callback);
Button4.attach(Button4_callback);
}
void loop() {
Blinker.run();
digitalWrite(5,LOW);
}
|