|
楼主 |
发表于 2019-8-6 07:07
|
显示全部楼层
第一个滑块成功后我又照猫画虎增加了第二个滑块但D4上的LED一直不亮,DEBUG和串口都能显示相关数据.,程序如下:
#define BLINKER_WIFI
#include <Blinker.h>
char auth[]="efca902628e4";
char ssid[]="";
char pswd[]="";
#define Slider_1 "SliderKey1"
#define Slider_2 "SliderKey2"
BlinkerSlider Slider1(Slider_1);
BlinkerSlider Slider2(Slider_2);
int i=0,j=0;
void slider1_callback(int32_t value)
{
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
BLINKER_LOG("get slider value: ", value);
i=value;
}
void slider2_callback(int32_t value)
{
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
BLINKER_LOG("get slider value: ", value);
j=value;
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print(BlinkerTime);
Blinker.print("millis", BlinkerTime);
Slider1.color("#FFFFFF");
Slider1.print(random(0, 128));
Slider2.color("#FFFFFF");
Slider2.print(random(0, 128));
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(D3,OUTPUT);
pinMode(D4,OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
Slider1.attach(slider1_callback);
Slider2.attach(slider1_callback);
}
void loop()
{
analogWrite(D3,i);
analogWrite(D4,j);
Blinker.run();
} |
|