Arduino car

Ok I have this arduino powered autonomes car. It uses a Sharp proximity sensor. It runs well when it does not sense anyting but when i put my hand near it sometimes is turns but other times it stops and the motor moves a tiny bit and then it stops.

Here is a video ..... - YouTube

Side comments

when it stops the tx and rx lights on the arduino are flashing (simmilar to when it finds an object). After a while (a minute or two... or sometimes never - have to restart it) when it continues going strait it stops blinking.

this is my code

int d1a=13;

int d2a= 12;

int s1= 10;

int d1b=11;

int d2b=8;

int sb=9;

int sensorPin = 5;

void setup () {  

  Serial.begin(9600);

  pinMode (d1a, OUTPUT);

  pinMode (d2a, OUTPUT);

  pinMode (s1, OUTPUT);

  pinMode (d1b, OUTPUT);

  pinMode (d2b, OUTPUT);

  pinMode (sb, OUTPUT);

}

void loop () {

  int val= analogRead (sensorPin);

  Serial.println (val); 

    if (val > 520) {

     analogWrite (10, 255);

digitalWrite (13 , HIGH);

digitalWrite (12, LOW);

analogWrite (9, 255);

digitalWrite (11 , HIGH);

digitalWrite (8, LOW);

delay (1500);

      analogWrite (10, 190);

digitalWrite (13 , HIGH);

digitalWrite (12, LOW);

analogWrite (9, 190);

digitalWrite (11 , LOW);

digitalWrite (8, HIGH);

  delay (1000);



    }

    else {

        analogWrite (10, 200);

digitalWrite (13 ,LOW);

digitalWrite (12, HIGH);

analogWrite (9, 200);

digitalWrite (11 , LOW);

digitalWrite (8, HIGH);

    }

}

(code tags added by moderator)

iint d1a=13;

shouldnt that be

"int d1a=13;"

Thanks... i dont know where that came from it wasnt in my actuall code... i fixed it though

oh alright, yeah im just learning so i cant help you.

Hi,

Are you powering everything from the same power source ? My guess is that when the robot wants to turn one of motors to do a lot more work somits pulling too much current which drops the battery voltage causing your uno to reset - have a look at tje two links in my signature, they relate to servos but its the same principle and solution.

Duane B

rcarduino.blogspot.com

Good idea.. I will look into it