Light Sensor(CDS)
A sensor whose resistance decreases as the light intensity increases.
Required Hardware
- Light Sensor (CDS)
- Arduino Board
- 10KΩ Resistor
- Jumper Cables
- LED (for example usage)
Connection
Even without using an LED, you can check the light sensor measurement values on the serial monitor.
Example Code
This example outputs the light sensor values to the serial monitor and changes the brightness of the LED based on the sensor values.
#define A_cds A0
void setup()
{
// Set serial communication baud rate
Serial.begin(9600);
}
void loop()
{
// Reads the voltage value coming in through analogRead.
// analogRead maps a voltage range of 0~5V to an integer value of 0~1024.
double value = analogRead(A_cds);
Serial.print("value : ");
Serial.println(value);
delay(1000);
}