"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!

Pictures :slight_smile:

IMG_2223.jpg

IMG_2224.jpg

IMG_2225.jpg

IMG_2227.jpg

 

As per your request! althought the stuff is in all sorts of awkward angles and there are wires everywhere so i don’t know if you can get a good look at it, but yeah :slight_smile: thanks so much for helping!

breadboard

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

As per the tutorial, i

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 
https://lh4.googleusercontent.com/-EgQK-VJRL54/TgHt3Sw1AxI/AAAAAAAAAPQ/Padivqv49YQ/s640/circuit.jpg
is anything wrong with it?

oh and i forgot to say, it

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

and also that code isn’t very good for servos

but we can look at that problem later

Sensor FIXED!

Oh my god! ok the sensor is fixed!

i dont know why, but some how the red wire of the sensor wasnt getting power from the 5V, when i plugged it directly in, the values made sense finally, then i pluged it back into its original position on the V row  of the bread board and it didnt work, then i moved it in the same row but one down to the left and it started working!? like just from hole 29 to hole 31 

Wow ok thanks so much! THANK YOU 

hmm although for some reason the max value seems to be about 600plus… it should be 1023 right?

Next problem is the motors :slight_smile:

yeah, you can unplug the 9v

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

deme.gif

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:

deme2.gif

check out the updated post

Calculon added another picture to his post above. He thinks this might be your problem.

OMG that makes so much sense

OMG that makes so much sense

i swear i always thought

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

Progress…

Ok. i followed your diagram and played around a bit and i have come up with this

As you can hopefully see, the 6v now goes directly to the voltage rail (36), and the connection to the servo red wire is on 38, and the connection to the sensor red wire is on 32. Ok, so what happens now is, when the USB is connected, everything is fine and dandy, (the servo works and so does the sensor) when the USB is disconected however, the servo makes these really weak pathetic lethargic attempts at movement (like its not getting enough power) and i don't know if the sensor works because i cant monitor the readings

probably a faulty connection somewhere

for whatever reason, the servo is relying on the 5v coming from your computer instead of the battery

600ish looks ok.

The output voltage from the sensor tops out just above 3V so you’re about right.

weak pathetic lethargic servos

im answering before reading but…

have you made sure you put pauses after each servo command to allow it to reach its position?

Ok!

Ok great, i used the voltmeter to check my 9 volt battery and it was only giving like 8 volts so i went out and bought a new battery and replaced it, now it works fine.

On to the Motor! hahaha (i really appreciate all the time and effort you guys are putting into helping me by the way, this is the first time i’m using a forum and i must say i did not expect people to be so helpful)

well…

we can be grumpy too

it must be a thursday thing

Solved.

Ok, i got someone to look at it, and we finally realised that the problem is that the stupid bread board Voltage rail does not run all the way through! thats it! i just shifted all my stuff up a bit and now its works great! Thank you for all your help :slight_smile: