Let's Make Robots!

"First Robot" Problems!

Hi everyone, 

I made my first robot according to the instructions from HERE : http://communityofrobots.com/tutorial/kawal/how-make-your-first-robot-using-arduino

After constructing the body and circuit of the robot, I put in the servo program, and that works fine so thats good

then i put in the sensor program, and when i upload it and it starts, i can see all the values come in on the serial monitor, but it doesnt vary much even if i put stuff in front of it (the number is supposed to get larger right?) but its stays within the range of like (0-200) and only when i use my finger to completely cover one of the lenses then all the numbers just become 00000000000
Then i tried putting in the motor program (for the wheels) and like the motors like completely just dont run at all, even if i set both to 'HIGH' and everything, i checked the circuits multiple times, and im pretty sure that i got it all right... but yeah, im not sure why it just like doesnt seem to be working, Oh and i'm not sure if this is supposed to happen, but when i take out one battery and put it back in for the 6V battery pack, the servo turns a bit (like, im not sure if thats supposed to happen) 
(also just a note, i used a H-Bridge motor driver IA instead of a L293D motor driver, because the person i bought it from said it could be substituted pin for pin)
Yup so i was just wondering what could be wrong, because i spent the whole of yesterday trying to figure it out and i couldnt, it would be great if you could help, Thanks!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

yeah, you can unplug the 9v and then connect the arduino to the Voltage from the Vin pin, like the pink line below:

also, this picture is wrong about the power rails. this picture shows the 6v going into the middle of the breadboard, when it should really be going right to the Voltage rail (the second from the bottom row), and a line should go from that row to the middle. like so:

OMG that makes so much sense

i swear i always thought something was wrong with that part of the diagram...

Perhaps the problem is that it's upside-down? Calculon has had lots of problems with breadboard connections in general. Sometimes the little tracks are just wide enough apart in spots that you can't make a dedicated connection. And that's WITHOUT the leads fighting gravity.

Other thoughts:

-can we look at your code? You mention that you "set both to High". Both pins? Or both motors?

-yes, it's normal for your servo to do that

-You don't need 2 battery packs. 6v can power both the motors and the controller. 

-your H-bridge needs to have all 4 V pins (the V and Enable pins)connected to V. Not the 5v in the arduino, but the V that's going INTO the arduino. The 'duino can't push enough current for those motors, the H-bridge should be pulling it direct from the battery. Also all, 4 Ground pins need to be connected to ground, and the arduino needs to be connected both the battery ground and the h-bridge's ground connection ("tying your grounds together") . 

-for the sensor, you may want to read the arduino documentaion about reference voltage

oh and i forgot to say, it doesnt work even when its upside down upside down, i.e. right side up

As per the tutorial, i copied and pasted this code

Now making the motors rotate.Copy paste or type the below code in the arduino IDE.


int motor_pin1 = 4;                 //define the pins to which motor wires are connected
int motor_pin2 = 5;
void setup ()
{
  pinMode(motor_pin1,OUTPUT);            // set the motor pins as output
  pinMode(motor_pin2,OUTPUT);
}

void loop()
{
  digitalWrite(motor_pin1,HIGH);
  digitalWrite(motor_pin2,LOW);
}

This will make one of your motor turn in one direction.The direction can be forward or backward.

when i said that i set both to high, i meant at the
digitalWrite(motor_pin1,HIGH);
digitalWrite(motor_pin2,HIGH);
- when you say i don't need two battery packs, do you mean i can just unplug my 9v? because i tried that while my servo was running and it just kind of died, or do i have to rewire stuff, and if so, in what way?
-erm yup all four of my V pins are connected to V, and all four of my ground pins are connected to ground
the middle part you kind of lost me, i just followed this diagram 
is anything wrong with it?
That's a nest, isn't it? From what I can see There's no way of telling where your sensor is wired. Also, The h-bridge needs to have a separate power supply for the motors than the Arduino uses too, so a second set of batteries is called for. You may try color coding and trimming your wiring a little just to keep track of things, but start with that.

you will see only one wire that looks like it is in the same column as the sense wire from the IR sensor. It moves up and to the left diagonally. Until it reaches the top of the picture and leaves the frame second from the left. On the last picture you will see that it plugs into D8.

I am more curious about the motor driver he used. Also, why do you say you can't use the same power for motors and logic? I agree that you can run into problems due to noise.

the wire which goes from D8 connects to the white wire of the servo

the yellow wire of the IR sensor connects to A0

erm, why are you curious about the motor driver he used? i thought it was a normal driver for small motors?

also i dont really know anything about the power sources for the motors and logic, i know that i have two sets of batteries, one 9V that goes to the arduino uno, and one 6V that goes.... somewhere else. did i say i cant use the same power for motors and logic? and i dont understand the problems that can arise due to noise, and noise from where?

Ahh i'm sorry for asking so many questions but im really clueless!

Best guess for the H-bridge is the SN754410 if it's pin for pin.  There are all sorts of great reasons to separate the power, especially with a higher-current chip like that, so I'm just going to go with the simple cop out that "...everybody knows you don't do that!"