(Another) Very basic electronics question.

Back story : I’m working on a robot with a light sensor, so I got off the breadboard and soldered together a light sensor that runs to ground, 5V, and the A0 pin.

What I did was returning only 1023 no matter the light source. (Or 0, I switched things around a little in “testing”).

I went back to the bread board, created the circuit again, and realized that I had soldered the A0 line between the resistor and ground, not between the photocell and the resistor. See the attached circuits (one is called “good”, one is called “bad”).

Now, I know that one works and one doesn’t so problem solved, but I don’t get why the one that doesn’t work, doesn’t work.

Shouldn’t A0 just pull a reading off the “circuit” I created? If light is low and R2 resistance is very high, I should get a low reading, and if the light is bright and R2 resistance is low, I should get a higher reading.

I don’t really see why the “bad” circuit is always reading 5V (or 0V. I swapped the ground and 5V around and forgot which way gave what), but the good circuit reads correctly.

Thanks. I know this is circuits 101 stuff. FTR, I got the same behavior in autodesk circuits. And, when I cut the joint and resoldered correctly everything worked, so I don’t think my soldering was a source of the problem.

In the "bad" diagram you have connected A0 to ground. No matter what else is attached to that connection, A0 will only see ground, nothing else.

Ah, that makes sense. I just made a little circuit with A0 and GND and it was just reading that. I thought that somehow it was "reading" the 5V -> R2 -> R1 -> GND circuit, but I see that now.

That also explains why when I switched the GND/5V leads for the same circuit, I was getting the opposite reading. Instead of 0, I was getting 1023.


You need to make a [u]voltage divider[/u] with the two resistors.

You need to make a [u]voltage divider[/u] with the two resistors.


Great piece of knowledge. That clears it up a lot. Thanks.