Subscribe to Arduino Academy and start learning today for FREE!

Light Sensing with a CdS (LDR)

A Cadmium Sulfide (CdS) sensor is a Light Dependent Resistor (LDR). It is a resistor that reduces resistance when hit with light. The more light, the lower the resistance. The Arduino is ideal for monitoring one of these sensors, and can be the heart of a streetlight or burglar alarm system, turning devices on or off in the presence of light. It could also be used in photography or solar applications, detecting the amount or direction of light.

See the following sketch for ideas. The parts are available at http://tinyurl.com/kdnqvys.

 

/*
Cds Connections:
CdS Pin 1 to +5v
CdS Pin 2 to Analog Pin 3
10k ohm resistor pin 1 to Analog Pin 3
10k ohm resistor pin 2 to Gnd
*/

int analogPin = 3;   // CdS (ldr) connected to analog pin 3
int val = 0;         // variable to store the read value

void setup() {
Serial.begin(9600);
}

void loop() {
val = analogRead(analogPin);   // read the input pin
Serial.println(val);
delay(100);
}

Become the Maker you were born to be. Try Arduino Academy for FREE!

 

 

 

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Archives

0
Would love your thoughts, please comment.x
()
x