|
楼主 |
发表于 2019-5-28 12:05
|
显示全部楼层
后来我直接连手机热点,响应速度也没变化,程序上我也尽可能的精简了,这是我的程序,麻烦您看一下是什么原因。
#define BLINKER_WIFI
#include <Blinker.h>
//#include <Servo.h>
int INA = D4; //电机A正反转控制端
int PWMA = D5; //电机A调速端
int INB = D7; //电机B正反转控制端
int PWMB = D6; //电机B调速端
char auth[] = "375e594d10f6";
char ssid[] = "bukaiyuan";
char pswd[] = "15910602089";
/*Servo myservo;
BlinkerSlider Slider1("duoji");
void slider1_callback(int32_t value)
{
myservo.write(value);
// BLINKER_LOG("get slider value: ", value);
}
*/
BlinkerButton Buttonqian("btn-qian");
void buttonqian_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
if (state=="press")
{
digitalWrite(INA,LOW);
digitalWrite(INB,HIGH);
analogWrite(PWMA,80);
analogWrite(PWMB,80);
}
else if(state=="pressup"){
digitalWrite(PWMA,LOW);
digitalWrite(PWMB,LOW);
}
}
BlinkerButton Buttonhou("btn-hou");
void buttonhou_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
if (state=="press")
{
digitalWrite(INA,HIGH);
digitalWrite(INB,LOW);
analogWrite(PWMA,80);
analogWrite(PWMB,80);
}
else if(state=="pressup"){
digitalWrite(PWMA,LOW);
digitalWrite(PWMB,LOW);
}
}
BlinkerButton Buttonzuo("btn-zuo");
void buttonzuo_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
if (state=="press")
{
digitalWrite(INA,HIGH);
digitalWrite(INB,HIGH);
analogWrite(PWMA,80);
analogWrite(PWMB,80);
}
else if(state=="pressup"){
digitalWrite(PWMA,LOW);
digitalWrite(PWMB,LOW);
}
}
BlinkerButton Buttonyou("btn-you");
void buttonyou_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
if (state=="press")
{
digitalWrite(INA,LOW);
digitalWrite(INB,LOW);
analogWrite(PWMA,80);
analogWrite(PWMB,80);
}
else if(state=="pressup"){
digitalWrite(PWMA,LOW);
digitalWrite(PWMB,LOW);
}
}
void setup()
{
analogWriteRange(255);
//myservo.attach(D5);
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(INA,OUTPUT);
pinMode(INB,OUTPUT);
pinMode(PWMA,OUTPUT);
pinMode(PWMB,OUTPUT);
Blinker.begin(auth, ssid, pswd);
Buttonqian.attach(buttonqian_callback);
Buttonhou.attach(buttonhou_callback);
Buttonzuo.attach(buttonzuo_callback);
Buttonyou.attach(buttonyou_callback);
}
void loop()
{
Blinker.run();
} |
|