如何解决如何一致地转动机器人轮胎
实际上,我对机器人轮胎功能有疑问。每当我发送命令转动机器人轮胎时,它并不会始终如一地转动,而是会停顿一下,例如运行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 举报,一经查实,本站将立刻删除。