I am building an Arduino car, which avoids obstacles and when I try to upload the code to my Arduino from the PlatformIO package of Atom I get an error message like this:
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0aaa
0x68 != 0x60
avrdude: verification error; content mismatch
avrdude done. Thank you.
This started happening a few days ago for no reason. It worked perfectly and suddenly I started getting this error message.
My code is:
#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);
}
}
}
Thank you.