Reed Switch Module(KY-025)

아두위키 : Arduwiki
ArduWiki (토론 | 기여)님의 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);
  }
}