问题描述
实际上,我对机器人轮胎功能有疑问。每当我发送命令转动机器人轮胎时,它并不会始终如一地转动,而是会停顿一下,例如运行2秒钟,停止4秒钟,请帮助我解决此问题。我已经尝试评论所有延迟功能,但是没有用。程序在下面。
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
int a;
int b;
int c;
int d;
// create servo object to control a servo
// twelve servo objects can be created on most boards
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "j3xYMHQA59RDWRLCsqBk3SWyDi_JP3FF";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "PTCL-BB";
char pass[] = "123ecostar";
// Hardware Serial on Mega,Leonardo,Micro...
//#define EspSerial Serial1
// or Software Serial on Uno,Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2,3); // RX,TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
WidgetTerminal terminal(V1);
// Attach virtual serial terminal to Virtual Pin V1
const int btnPin = 4;
WidgetLED led3(V3);
BlynkTimer timer;
// V3 LED Widget represents the physical button state
boolean btnState = false;
void buttonLedWidget()
{
// Read button
boolean ispressed = (digitalRead(btnPin) == LOW);
// If state has changed...
if (ispressed != btnState) {
if (ispressed) {
led3.on();
} else {
led3.off();
}
btnState = ispressed;
}
terminal.print("HYDROGEN=:");
terminal.print(a-100);
terminal.print("ppm");
terminal.println();
terminal.print("LPG=:");
terminal.print(b-100);
terminal.print("ppm");
terminal.println();
terminal.print("CH4=:");
terminal.print(c-100);
terminal.print("ppm");
terminal.println();
terminal.print("CO=:");
terminal.print(d-100);
terminal.print("ppm");
terminal.println();
}
void setup()
{
// Debug console
Serial.begin(9600);
//bridge1.digitalWrite(13,1000);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
//pinMode(4,INPUT);
Blynk.begin(auth,wifi,ssid,pass);
pinMode(btnPin,INPUT_PULLUP);
timer.setInterval(500L,buttonLedWidget);
}
void loop()
{
Blynk.run();
timer.run();
a = analogRead(A0);
b =analogRead(A1);
c = analogRead(A2);
d = analogRead(A3);
//delay(1000);
}
void forward(){
digitalWrite(10,HIGH);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(10,LOW);
digitalWrite(8,LOW);
}
void left(){
digitalWrite(10,LOW);
}
void right(){
digitalWrite(10,LOW);
delay(100);
digitalWrite(10,LOW);
}```
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)