Light Sensor(CDS): 두 판 사이의 차이

아두위키 : Arduwiki
잔글편집 요약 없음
잔글편집 요약 없음
1번째 줄: 1번째 줄:
{{#seo:|title=아두위키 : 아두이노 조도 센서 가이드|title_mode=append|keywords=아두이노, 정보과학, 메이커학습, 수행평가, 조도 센서, 아두이노 작품, 캡스톤작품, 아두이노 예제코드|description=아두이노로 조도 센서를 사용하는 방법(기본정보, 회로, 예제 코드)를 소개합니다. 정보과학과 메이커수업에 활용가능합니다.}}
{{#seo:|title=ArduWiki : Arduino Light Sensor Guide|title_mode=append|keywords=Arduino, Computer Science, Maker Learning, Performance Assessment, Light Sensor, Arduino Project, Capstone Project, Arduino Example Code|description=Introduces how to use a light sensor with Arduino (basic info, circuit, example code). Useful for computer science and maker classes.}}[[파일:조도센서대표이미지.jpg|가운데|class=coders100]]This is a sensor whose resistance decreases as the brightness increases.
[[File:조도센서대표이미지.jpg|center|class=coders100]]
 
A sensor whose resistance decreases as the light intensity increases.


== '''Required Hardware''' ==
== '''Required Hardware''' ==


* Light Sensor (CDS)
* Light Sensor (CDS)
* Arduino Board
* [[아두이노(Arduino)|Arduino Board]]
* 10KΩ Resistor
* [https://gongzipsa.com/shop/1699939292 10K'''Ω''' Resistor]
* Jumper Cables
* [https://gongzipsa.com/shop/1699939289 Jumper Wires]
* [[LED 5mm EN|LED (for example usage)]]
* [[LED 5mm EN|LED]] (used in example)
 
 
== '''Connection''' ==
Even without using an LED, you can check the light sensor readings through the serial monitor.
[[파일:LED 사용x 회로.png|없음|프레임|class=coders100|Circuit without LED]]
[[파일:LED 사용시 회로 .png|없음|프레임|class=coders100|Circuit with LED]]


== Connection ==
Even without using an LED, you can check the light sensor measurement values on the serial monitor.
[[File:LED 사용x 회로.png|none|class=coders100|frame|Circuit without LED]]
[[File:LED 사용시 회로 .png|none|class=coders100|frame|Circuit with LED]]


== '''Example Code''' ==
== '''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.<syntaxhighlight lang="c++" line="1">
This example prints the light sensor value to the serial monitor and adjusts the LED brightness based on the sensor value.<syntaxhighlight lang="c++" line="1">
#define A_cds A0
#define A_cds A0


void setup()
void setup()
{
{
   // Set serial communication baud rate
   // Set the serial communication baud rate
   Serial.begin(9600);
   Serial.begin(9600);
}
}
28번째 줄: 29번째 줄:
void loop()
void loop()
{
{
   // Reads the voltage value coming in through analogRead.
   // Read voltage input via analogRead
   // analogRead maps a voltage range of 0~5V to an integer value of 0~1024.
   // analogRead maps 0–5V to integer values between 0–1024
   double value = analogRead(A_cds);
   double value = analogRead(A_cds);
   Serial.print("value : ");
   Serial.print("value : ");
35번째 줄: 36번째 줄:
   delay(1000);
   delay(1000);
}
}
</syntaxhighlight>
</syntaxhighlight>


=== Execution Result ===
=== Output Result ===
[[File:LED 테스트 .png|alt=조도 센서를 가리지 않았을 때() 조도 센서를 가렸을 때() LED 밝기 비교|none|class=coders100|frame|Comparison of LED brightness when the light sensor is not covered (left) versus when it is covered (right).]]
[[파일:LED 테스트 .png|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)|프레임|없음]]

2025년 3월 27일 (목) 14:00 판

This is a sensor whose resistance decreases as the brightness increases.


Required Hardware


Connection

Even without using an LED, you can check the light sensor readings through the serial monitor.

Circuit without LED
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

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)