LDR

This follows on from the Potentiometer’s example.

CIRCUIT:

Light Dependent Resistor

To build this circuit, push the LDR into the breadboard with one leg connecting to A7 and the other to the ground rail. Plug a 10k resistor from the 5v power rail to the same analog pin, A7.

A LDR or Light Dependent Resistor varies its resistance depending on the amount of light shining on it. This variance changes the voltage we read on the analog pin.

CODE:

 

Did you notice on this line ldrValue = map(ldrValue , 0, 1023, 255, 0); we reversed the 0 and 255? This means that the lower the voltage read (less light) the higher we make the value we write to the LED, making it brighter.

Leave a Reply

Your email address will not be published. Required fields are marked *