Light Sensor(CDS)

아두위키 : Arduwiki

A sensor whose resistance decreases as the light intensity increases.

Required Hardware

Connection

Even without using an LED, you can check the light sensor measurement values on the serial monitor.

Circuit without LED
Circuit with LED

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);
}

Execution Result

조도 센서를 가리지 않았을 때(좌) 조도 센서를 가렸을 때(우) LED 밝기 비교
Comparison of LED brightness when the light sensor is not covered (left) versus when it is covered (right).