Light Sensor(CDS): 두 판 사이의 차이
(Created page with "{{#seo:|title=아두위키 : 아두이노 조도 센서 가이드|title_mode=append|keywords=아두이노, 정보과학, 메이커학습, 수행평가, 조도 센서, 아두이노 작품, 캡스톤작품, 아두이노 예제코드|description=아두이노로 조도 센서를 사용하는 방법(기본정보, 회로, 예제 코드)를 소개합니다. 정보과학과 메이커수업에 활용가능합니다.}} [[File:조도센서대표이미지.jpg|center|class=coders100]...") |
잔글편집 요약 없음 |
||
| (같은 사용자의 중간 판 2개는 보이지 않습니다) | |||
| 1번째 줄: | 1번째 줄: | ||
{{#seo:|title= | {{#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. | ||
[[ | |||
== '''Required Hardware''' == | == '''Required Hardware''' == | ||
| 8번째 줄: | 7번째 줄: | ||
* Arduino Board | * Arduino Board | ||
* 10KΩ Resistor | * 10KΩ Resistor | ||
* Jumper | * Jumper Wires | ||
* [[LED 5mm|LED ( | * [[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]] | |||
== '''Example Code''' == | == '''Example Code''' == | ||
This example | 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() | ||
{ | { | ||
// | // Read voltage input via analogRead | ||
// analogRead maps | // 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> | ||
=== | === Output Result === | ||
[[ | [[파일: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:01 기준 최신판

This 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.


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
