【问题标题】:Why do I get a verification error when trying to upload my code to my Arduino?为什么在尝试将代码上传到我的 Arduino 时出现验证错误?
【发布时间】:2020-04-15 13:05:00
【问题描述】:

我正在建造一辆 Arduino 汽车,它可以避开障碍物,当我尝试将代码从 Atom 的 PlatformIO 包上传到我的 Arduino 时,我收到如下错误消息:

avrdude: 正在验证 ...
avrdude: 验证 错误, em> first 不匹配 at 字节 0x0aaa
0x68 != 0x60
avrdude: 验证 错误; 内容 不匹配

avrdude 完成。 谢谢。

几天前无缘无故开始发生这种情况。它运行良好,突然间我开始收到此错误消息。

我的代码是:

#include <Arduino.h>
#include <Servo.h>

const int trigPin = 6;
const int echoPin = 7;
const int motorRF = 3;
const int sleep = 4;
const int motorRB = 9;
const int motorLF = 10;
const int motorLB = 11;

int minDistance = 350;
long value;
int speed = 1000;
int randNum;

void setup() {
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);

    pinMode(motorRF, OUTPUT);
    pinMode(motorRB, OUTPUT);
    pinMode(motorLF, OUTPUT);
    pinMode(motorLB, OUTPUT);
    pinMode(sleep, OUTPUT);

    Serial.begin(9600);
}

//Define the directions of the motors
void forward() {
    analogWrite(motorRF, speed);
    analogWrite(motorLF, speed);
    analogWrite(motorRB, 0);
    analogWrite(motorLB, 0);
}
void backward() {
    analogWrite(motorRF, 0);
    analogWrite(motorLF, 0);
    analogWrite(motorRB, speed);
    analogWrite(motorLB, speed);
}
void right() {
    analogWrite(motorRF, 0);
    analogWrite(motorLF, speed);
    analogWrite(motorRB, speed);
    analogWrite(motorLB, 0);
}
void left() {
    analogWrite(motorRF, speed);
    analogWrite(motorLF, 0);
    analogWrite(motorRB, 0);
    analogWrite(motorLB, speed);
}

void loop() {
//Ultrasonic sensor
    digitalWrite(trigPin, LOW);
    delayMicroseconds(5);

    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);

    value = pulseIn(echoPin, HIGH);
    Serial.println("Value = "); Serial.println(value);

    delay(50);

//Motors
    digitalWrite(sleep, HIGH);
    if(value > minDistance) {
    //Drive forward
        backward();
    }
    else {
    //Drive backward
        forward();
        delay(1000);

    //Pick between number 1 and 2
        randNum = random(0, 2);
        Serial.println("Random Num = "); Serial.println(randNum);

    //If the number is 2 then drive right
        if(randNum == 1) {
            right();
            delay(500);
        }
    //Else drive left
        else {
            left();
            delay(500);
        }
    }
}

谢谢。

【问题讨论】:

  • 这感觉像是硬件问题。当您使用不同的 Arduino 时会出现问题吗?
  • 在做了一些研究之后,我有了同样的想法。我订购了一些新的 Arduino,看看是否是硬件问题(它们还没有到货)。我会告诉你我是否和他们有同样的问题。谢谢回复:)

标签: c++ arduino atom-editor platformio


【解决方案1】:

这是硬件问题。程序很好。我试图将它上传到另一个 Arduino,它运行良好。谢谢。

【讨论】:

    猜你喜欢
    • 2019-01-05
    • 2022-07-08
    • 1970-01-01
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多