Noise and Impedance on Analog Inputs
If you we very observant when we used the LED as a light sensor, you might have noticed that the output seemed to move around a lot. Much more than you would expect, since the light probably did not seem to change much while you watched.
Analog inputs are sensitive to what we call noise, which is electrical changes in the system that are not due to changes in the system being measured. Noise comes from small changes in the computer's power supply voltage, from radio waves, and from heat, among other things.
To overcome noise, we can raise the signal level from the sensor. This is often done by adding an amplifier. But in our case, we can simply replace the LED with a sensor that has a larger light gathering area, such as a small solar cell. You can get one economically by taking apart some cheap or broken solar powered device, such as a solar garden light, or a small solar powered toy or calculator.
The LED, with its tiny surface area, can't produce very much electrical current. We say that something that does not produce a lot of current has a high impedance to electrical current. This can be because it has a lot of resistance, or simply because, as in our case, it just doesn't produce much output. In an output, a high impedance is a bad thing.
In an input, a high impedance is a good thing. It means that the thing doing the measuring (in this case the A0 pin of the tiny computer) does not change the voltage of the sensor output very much. As an analogy, we might say that a big thermometer would cool the tea we are taking the temperature of, but a small thermometer would cool it less. The big thermometer has a low impedance to heat, and the small thermometer has a high impedance, so not much heat is drawn from the tea.
So we want our sensor outputs to be low impedance, and our analog inputs to have a high impedance. If the impedance of the sensor output is too similar to the impedance of the analog input, we get noise, and our measurements seem to wander.
As we will see later, there are other ways to reduce or eliminate noise, by abandoning analog inputs altogether, and using clever digital techniques.