Today we are looking on how we can use the analog input on arduino, to read a sensor. This is basic knowledge but very useful in robotic projects.
So what is an analog input? Unlike the digital input which can read two states, 0 or LOW or no voltage and 1 or HIGH or high voltage, the analog input can read up to 1024 different states which are 0,1,2,3,4,...,1022,1023. These are voltage equivalents for when you break 5V into 1024 equal "pieces" of 0.00488V each. That means that 0V is 0, 0.00488V is 1, 0.00977V is 2, ... , 4.99512V is 1023. So basically what the input is, is a scale of 0-5V in 1024 states.
Now let's see how a sensor works. Most sensors use a physical characteristic to transform the physical property that you want to measure into something that can be used in an electrical circuit.
The Light Dependent Resistor, as it name suggests is a resistor whose value changes depending an how much light it receives on it's top. The more light it gets that less resistive it becomes, i.e. more current can pass through it. But remember we said that the input on arduino can only read voltage? So how do we transfrom this resistance change into voltage change?