Reed Switch Module(KY-025): 두 판 사이의 차이
잔글편집 요약 없음 |
|||
| 1번째 줄: | 1번째 줄: | ||
{{#seo:|title= | {{#seo:|title=ArduWiki : Arduino Reed Switch Module Guide|title_mode=append|keywords=Arduino, Computer Science, Maker Learning, Performance Assessment, Reed Switch Module, Arduino Project, Capstone Project, Arduino Example Code|description=Introduces how to control a reed switch module with Arduino (basic info, wiring, example code). Useful for computer science and maker classes.}} | ||
[[ | [[파일:리드스위치 대표이미지.jpg|가운데|class=coders100]] | ||
A switch module that operates magnetically. | A switch module that operates magnetically. | ||
2025년 3월 27일 (목) 15:13 기준 최신판

A switch module that operates magnetically.
Specifications
- Operating Voltage: 3.3V ~ 5V
- Note: Although it has an analog output terminal, it only outputs 0 or 1023.
Example Hardware Used
- Arduino Board
- Jumper Cables
- LED (5mm)
- Reed Switch Module
Connection
| Reed Switch | LED | Arduino | ||
| GND | - | GND | ||
| + | D8 | |||
| + | 5V | |||
| DO | D7 | |||

Example Code
This code turns on an LED depending on the state of the reed switch.
int reed = 7;
int led = 8;
void setup() {
pinMode(reed, INPUT);
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}
void loop() {
if (digitalRead(reed) == HIGH) {
digitalWrite(led, HIGH);
} else {
digitalWrite(led, LOW);
}
}