|
大概的功能就是实现电机的开关功能,和调节速度功能,但是如何实现开的时候读取当前滑条的值呢?本人新手看arduino基础估计没那么快实现想要的功能了,还是请教一下各位大佬了!感谢
#define BLINKER_WIFI
#include <Blinker.h>
char auth[] = "ea875gdh2155";
char ssid[] = "66666";
char pswd[] = "88888";
#define Slider_1 "SliderKey1"
BlinkerSlider Slider1(Slider_1);
BlinkerButton Button1("btn-abc");
BlinkerButton Button2("btn-q");
BlinkerButton Button3("btn-t");
void slider1_callback(int32_t value)
{
BLINKER_LOG("get slider value: ", value);
analogWrite(D11,value);
}
void button1_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
Blinker.vibrate();
}
void button2_callback(const String & state ) {
BLINKER_LOG("get button state: ", state);
digitalWrite(D13, LOW);
analogWrite(D11,255);
}
void button3_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
digitalWrite(D13, LOW);
digitalWrite(D11,LOW);
}
void setup() {
// 初始化串口,并开启调试信息
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
// 初始化有LED的IO
pinMode(LED_BUILTIN, OUTPUT);
pinMode(D11, OUTPUT);
pinMode(D13, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
// 初始化blinker
Blinker.begin(auth, ssid, pswd);
Slider1.attach(slider1_callback);
Button1.attach(button1_callback);
Button2.attach(button2_callback);
Button3.attach(button3_callback);
}
void loop() {
Blinker.run();
} |
|