描述
技術規格
1.訊號傳輸型式: 數位 (Digital)
2.磁感元件:MKA-14103
3.模組尺寸:40 x 30 mm
4.工作電壓: 5.0V
商品內容
- 磁簧開關模組 1個
- RJ11 6P4C 25cm 信號線 1條
程式範例
// Reed Switch Moduke
const int switchPin = 3; // Reed switch to digital pin 3
const int ledPin = 11; // the pin that the LED is attached to D11
void setup() {
pinMode(switchPin, INPUT); // switchPin is an input
Serial.begin(9600);
}
void loop() {
int pgmState = digitalRead(switchPin);
if (pgmState == HIGH) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
delay(1000);
}