Light Sensor(CDS)

아두위키 : Arduwiki

가운데|class=coders100This is a sensor whose resistance decreases as the brightness increases.


Required Hardware

  • Light Sensor (CDS)
  • Arduino Board
  • 10KΩ Resistor
  • Jumper Wires
  • LED (used in example)


Connection

Even without using an LED, you can check the light sensor readings through the serial monitor. 없음|프레임|class=coders100|Circuit without LED 없음|프레임|class=coders100|Circuit with LED


Example Code

This example prints the light sensor value to the serial monitor and adjusts the LED brightness based on the sensor value.

#define A_cds A0

void setup()
{
  // Set the serial communication baud rate
  Serial.begin(9600);
}

void loop()
{
  // Read voltage input via analogRead
  // analogRead maps 0–5V to integer values between 0–1024
  double value = analogRead(A_cds);
  Serial.print("value : ");
  Serial.println(value);
  delay(1000);
}

Output Result

class=coders100|Comparison of LED brightness when light sensor is uncovered (left) vs. covered (right)|대체글=Comparison of LED brightness when light sensor is uncovered (left) vs. covered (right)|프레임|없음