Arduino Robot

Hello my name is jack.I am making a robot(obstacle avoiding) with Arduino Uno R3.I powered it with 4.8v(four eneloop batteries AA- 2450mAh) and nothing happens.The green light of Arduino is green but is not responding.I don't know what to do.The materials that i used are Fitec FS5106B servo - Operating Voltage : 4.8V~6V Sharp Sensor GP2D12 - voltage : 4.5 to 5.5 V Robot Chassis informations(http://www.ebay.com/itm/Smart-Robot-Car-Chassis-Kits-with-Speed-encoder-Battery-Box-for-Arduino-3v-5v-6v-/400569524921?pt=LH_DefaultDomain_0&hash=item5d43cde2b9)

Please help me, you are my last hope. if you want more information about my robot, please ask me.

You'll have to supply a lot more info than that... like your code and a schematic for example.

Have you tried a different sketch in the Arduino to be sure it's not faulty?- like blink maybe?

The code that i use

#include <Servo.h> //includes the servo library

int motor_pin1 = 4;
int motor_pin2 = 5;
int motor_pin3 = 6;
int motor_pin4 = 7;
int servopin = 8;
int sensorpin = 0;
int dist = 0;
int leftdist = 0;
int rightdist = 0;
int object = 500; //distance at which the robot should look for another route

Servo myservo;

void setup ()
{
pinMode(motor_pin1,OUTPUT);
pinMode(motor_pin2,OUTPUT);
pinMode(motor_pin3,OUTPUT);
pinMode(motor_pin4,OUTPUT);
myservo.attach(servopin);
myservo.write(90);
delay(700);
}
void loop()
{
dist = analogRead(sensorpin); //reads the sensor

if(dist < object) { //if distance is less than 550
forward(); //then move forward
}
if(dist >= object) { //if distance is greater than or equal to 550
findroute();
}
}

void forward() { // use combination which works for you
digitalWrite(motor_pin1,HIGH);
digitalWrite(motor_pin2,LOW);
digitalWrite(motor_pin3,LOW);
digitalWrite(motor_pin4,HIGH);
return;
}

void findroute() {
halt(); // stop
backward(); //go backwards
lookleft(); //go to subroutine lookleft
lookright(); //go to subroutine lookright

if ( leftdist < rightdist )
{
turnleft();
}
else
{
turnright ();
}
}

void backward() {
digitalWrite(motor_pin1,HIGH);
digitalWrite(motor_pin2,LOW);
digitalWrite(motor_pin3,HIGH);
digitalWrite(motor_pin4,LOW);
delay(500);
halt();
return;
}

void halt () {
digitalWrite(motor_pin1,LOW);
digitalWrite(motor_pin2,LOW);
digitalWrite(motor_pin3,LOW);
digitalWrite(motor_pin4,LOW);
delay(500); //wait after stopping
return;
}

void lookleft() {
myservo.write(150);
delay(700); //wait for the servo to get there
leftdist = analogRead(sensorpin);
myservo.write(90);
delay(700); //wait for the servo to get there
return;
}

void lookright () {
myservo.write(30);
delay(700); //wait for the servo to get there
rightdist = analogRead(sensorpin);
myservo.write(90);
delay(700); //wait for the servo to get there
return;
}

void turnleft () {
digitalWrite(motor_pin1,HIGH); //use the combination which works for you
digitalWrite(motor_pin2,LOW); //right motor rotates forward and left motor backward
digitalWrite(motor_pin3,LOW);
digitalWrite(motor_pin4,HIGH);
delay(1000); // wait for the robot to make the turn
halt();
return;
}

void turnright () {
digitalWrite(motor_pin1,LOW); //use the combination which works for you
digitalWrite(motor_pin2,HIGH); //left motor rotates forward and right motor backward
digitalWrite(motor_pin3,HIGH);
digitalWrite(motor_pin4,LOW);
delay(1000); // wait for the robot to make the turn
halt();
return;
}

how many volatge Arduino can handle?(i connect it to gnd and 5v pin).How voltage my robot needs to work properly?
I don’t have tried different sketch.

Have I got this right: you're supplying the Uno with 5V through the 5V pin? That's really a power out pin....

Read this, which is from the Uno product page

5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.

If that's how you did it you might like to rethink that.

I haven't checked all the circuit, but maybe you should try to get it to work a bit at a time. Comment out all the code except the servo code for example, and have only the servo connected; see if that works. (Edit... although that's not too easy given the structure of the code. Maybe load and run the sweep program to check the servo works on its own? Sweep is in the IDE: File>Examples>Servo)

Yes i am supplying the Uno with 5V through the 5V pin.I tried to upload the sweep code in File>Examples>Servo but without result. The green light of arduino is green but the servo doesn't respond.I don't know what to do.Something else to try?

When upload my code the right wheel and servo work.

Jack_Jason: Yes i am supplying the Uno with 5V through the 5V pin........Something else to try?

For a start, I think you should follow the maker's instructions and not power it that way.

I tried to supply Arduino, like the schematic i send(not with 5v and gnd pin)but it moves little.Maybe fault the voltage?or my code?

If I were you I’d disconnect everything except the servo, with the Arduino powered say thru your PC USB, and separate power to the servo. It would look like the attached but obviously just one servo. Load sweep. See what happens then.

Many servos- small.jpg

Sorry but i don't know how to do this, robot is created by one friend, we don't speak anymore.Anyway, i removed all cables and i make the schematic again.I think i find my problem.My problem is voltage, is not enough to power all my components.If i don't become annoying i would like to tell me how many voltage my robot needs to work properly.

I put the four eneloop batteries(4x1.2=4.8v)+9v battery(total 13.8v),The right gear motor moves fine but the left moves barely.Servo and Sensor seems are fine.