求助怎样用blinker滑块例程来控制led灯亮度
blinker滑块例程void slider1_callback(int32_t value)的value值怎样调用,加最简程序来实现模拟写analogWrite(D5,?).控制D5端LED灯的亮度恳请各位大神指教谢谢void slider1_callback(int32_t value)
{
analogWrite(pin,value);
} 谢谢奈何老师及时回复,我试验后就好了.我以前这样做过:
void slider1_callback(int32_t value)
{
i=value;
} loop( )
{
analogWrite(D3,i);
]
但没成功,一定是我有地方搞错了 再补充一点value最大值为1000,D3端口电压才能达到3V,(8266的原因). 第一个滑块成功后我又照猫画虎增加了第二个滑块但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();
} Slider1.attach(slider1_callback);
Slider2.attach(slider2_callback);
谢谢您的回复,我已发现这个原因.并试验成三滑块的程序.昨天我就发贴" blinker滑块控制RGB三色LED灯亮度和色彩"供大家分享.
页:
[1]