Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arduino 如何使机器人轮胎转动一致_Arduino_Robot_Chain_Blynk - Fatal编程技术网

Arduino 如何使机器人轮胎转动一致

Arduino 如何使机器人轮胎转动一致,arduino,robot,chain,blynk,Arduino,Robot,Chain,Blynk,事实上,我有一个机器人轮胎功能的问题。每次我发送命令来转动机器人轮胎时,它不会以一致的方式转动,但有时会暂停,例如运行2秒和停止4秒,请帮助我解决此问题。我试着对所有的延迟功能进行注释,但没有效果。节目如下 #define BLYNK_PRINT Serial #include <ESP8266_Lib.h> #include <BlynkSimpleShieldEsp8266.h> int a; int b; int

事实上,我有一个机器人轮胎功能的问题。每次我发送命令来转动机器人轮胎时,它不会以一致的方式转动,但有时会暂停,例如运行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);
    digitalWrite(8,HIGH);
    delay(100);
    digitalWrite(10,LOW);
    digitalWrite(8,LOW);
    }
    void right(){
    digitalWrite(10,HIGH);
    digitalWrite(8,LOW);
    delay(100);
    digitalWrite(10,LOW);
    digitalWrite(8,LOW);
    }```
#定义BLYNK#u打印序列
#包括
#包括
INTA;
int b;
INTC;
int d;
//创建伺服对象以控制伺服
//大多数电路板上可以创建12个伺服对象
//你应该在Blynk应用程序中获得身份验证令牌。
//转到项目设置(螺母图标)。
char auth[]=“j3xYMHQA59RDWRLCsqBk3SWyDi_JP3FF”;
//您的WiFi凭据。
//将开放网络的密码设置为“”。
字符ssid[]=“PTCL-BB”;
char pass[]=“123ecostar”;
//Mega、Leonardo、Micro上的硬件系列。。。
//#定义EspSerial Serial1
//或者Uno上的软件序列,Nano。。。
#包括
软件系列EspSerial(2,3);//接收,发送
//您的ESP8266波特率:
#定义ESP8266_波特9600
ESP8266 wifi(和EspSerial);
WidgetTerminal终端(V1);
//将虚拟串行终端连接到虚拟引脚V1
常数int btnPin=4;
WidgetLED led3(V3);
BlynkTimer定时器;
//V3 LED小部件表示物理按钮状态
布尔值btnState=false;
void buttonLedWidget()
{
//阅读按钮
布尔值isPressed=(数字读取(btnPin)=低);
//如果国家改变了。。。
如果(isPressed!=btnState){
如果(显示){
led3.on();
}否则{
led3.off();
}
btnState=已压缩;
}
终端打印(“氢=:”;
终端打印(a-100);
终端打印(“ppm”);
terminal.println();
终端打印(“LPG=:”;
终端打印(b-100);
终端打印(“ppm”);
terminal.println();
terminal.print(“CH4=:”);
终端打印(c-100);
终端打印(“ppm”);
terminal.println();
terminal.print(“CO=:”);
终端打印(d-100);
终端打印(“ppm”);
terminal.println();
}
无效设置()
{
//调试控制台
Serial.begin(9600);
//bridge1.数字写入(131000);
//设置ESP8266波特率
EspSerial.begin(ESP8266_波特);
延迟(10);
//pinMode(4,输入);
Blynk.begin(身份验证、wifi、ssid、通行证);
pinMode(btnPin,输入\上拉);
定时器。设置间隔(500L,buttonLedWidget);
}
void循环()
{
Blynk.run();
timer.run();
a=模拟读数(A0);
b=模拟读数(A1);
c=模拟读数(A2);
d=模拟读数(A3);
//延迟(1000);
}
作废远期汇票(){
数字写入(10,高);
数字写入(8,高);
延迟(100);
数字写入(10,低);
数字写入(8,低);
}
左空(){
数字写入(10,低);
数字写入(8,高);
延迟(100);
数字写入(10,低);
数字写入(8,低);
}
无效权利(){
数字写入(10,高);
数字写入(8,低);
延迟(100);
数字写入(10,低);
数字写入(8,低);
}```