DFRobotshop Rover keeps stopping then automatically restarts

Hello,
My DFRobotShop Rover keeps automatically restarting followed by a malfunction in which it repeatedly goes in a circle. This occurs about 1-5 seconds after I turn it on.
The rover is supposed to run autonomously by means of the HC-SR04 ultrasonic sensor. As of now, this is the only additional module I have attached.

Pins for this are as follows:
Pin 10 - Trigger
Pin 11 - Echo
Common GND
Vcc to the boards 5VI ran the full speed test and it seems to work fine.
Has anyone else ran into this problem?

This is the code I have wrote for it:

#include <LiquidCrystal.h>
#include <Ultrasonic.h>
LiquidCrystal lcd(11, 10, 9, 4, 3, 2);
Ultrasonic ultrasonic(10,11); //Pin 10 is Trig. Pin 11 is Echo
const int M1Speed = 6; //M1 Speed Control
const int M2Speed = 5; //M2 Speed Control
const int M1Direction = 8; //M1 Direction Control
const int M2Direction = 7; //M2 Direction Control
int steeringMotorSpeed = 200;
int avoidDistance = 20;
int endAvoidDistance = 50;
int goToReverseDistance = 20;
int reverseTime = 1000;
int fullThrottleMinDistance = 50;
int lowSpeed = 0;
int fullThrottleSpeed = 255;
int cruiseSpeed = 200;
int avoidSpeed = 185;
int reverseSpeed = 175;
int sensorDelay = 200;  //  
int avoidDirection = 1;
int distance; //averaged distance
const int numReadings = 10;
int readings[numReadings];  // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0;    // the running total
void setup() {
Serial.begin(9600);
pinMode(M1Speed, OUTPUT);
pinMode(M2Speed, OUTPUT);
pinMode(M1Direction, OUTPUT);
pinMode(M2Direction, OUTPUT);
// initialize serial communication with computer:
Serial.begin(9600);
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}
void loop() {
distance = (ultrasonic.Ranging(CM));
Serial.println(distance);
if (distance <= goToReverseDistance){
reverseMode ();

}else if (distance > goToReverseDistance && distance <= avoidDistance){
avoidMode();
}else if (distance > avoidDistance && distance < fullThrottleMinDistance){
cruiseMode();
}else if (distance >= fullThrottleMinDistance){
fullThrottleMode();
}
delay(sensorDelay);
}
void reverseMode(){

avoidDirection = avoidDirection * -1;
digitalWrite(M1Direction, HIGH);
digitalWrite(M2Direction, LOW);

analogWrite(M2Speed, reverseSpeed);
analogWrite(M1Speed, reverseSpeed);

delay(sensorDelay);
}
void avoidMode(){ 

distance = (ultrasonic.Ranging(CM));

digitalWrite(M1Direction, LOW); //Turn one way
digitalWrite(M2Direction, LOW);
analogWrite(M1Speed, fullThrottleSpeed);
analogWrite(M2Speed, avoidSpeed); 

delay(sensorDelay);
}
void cruiseMode(){ 

digitalWrite(M1Direction, LOW);
digitalWrite(M2Direction, LOW);

analogWrite(M1Speed, cruiseSpeed);
analogWrite(M2Speed, cruiseSpeed);

delay(sensorDelay);
}
void fullThrottleMode(){
digitalWrite(M1Direction, LOW);
digitalWrite(M2Direction, LOW);

analogWrite(M1Speed, fullThrottleSpeed);
analogWrite(M2Speed, fullThrottleSpeed);

delay(sensorDelay);
}

Note: Inside this code there is a little from the smoother code in the setup function



Could you attach a file with a copy of a typical output on the serial monitor when this sketch is running?

Also, it may help to have a short video of the behavior when this issue happens.

Sincerely,

Here is a chunk of readings that I got from my serial monitor
When the rover is plugged into the computer, it works almost perfectly but as soon as I unplug it, lights dim, and then 3 seconds later it malfunctions.
9
9
9
13
23
35
46
57
67
48
48
49
49
79
79
49
50
51
77
76
74
74
75
75
75
76
76
76
77
77
50
50
52
77
77
78
77
77
52
79
78
77
78
78
77
78
80
81
53
49
49
49
48
44
39
31
23
16
11
8
7
5
4
4
4
4
4
4
8
60
61
77
56
56
49
49

Also, I couldn’t upload the video from my IPad due to its extension .mov

Hi,

What you describe sounds like a power issue. What are you using to power the rover? If you are using primary batteries (non-rechargeable), such as AA, make sure they provide at least 1.5 V DC each (check each with a multimeter). If you need to replace them, it is recommend to replace all of them at once.
If you are using secondary battery (rechargeable), such as rechargeable AA or a LiPo, make sure it is sufficiently charged to provide enough voltage/current to your rover.

Sincerely,

Hello,

I am using 4 AA batteries rated at 1.5V brand new and no secondary batteries.
I tested the voltages and they came to a total of 5.09 V DC. I believe that at this voltage it should still run.

Thanks

Hi,

Well, you may want to verify your battery holder and the AAs in it, as 4x1.5 V should be equal to 6.0 V DC, not 5.09 V DC.

With the batteries connected to the rover, please use a multimeter and check the voltage output from the 5V pin with respect to ground. Is it a nice ~5.0 V DC or is it lower? Please let us know in your reply how much voltage it is providing.

Also, you may want to try and wire the batteries directly to the Vin pin and see if that works.

Sincerely,

Hey,

I measured and it stands at a 5.1 V.
I also tried Vin and had no luck. It continued its usual crazy behavior.

Thanks

Do you have any other suggestions?
I need to get this rover working.

Hi,

Since we are unable to determine the exact cause of your issue, we will assume your rover is defective. Someone will be contacting you through our support center shortly (via your existing support ticket).

Sincerely,