아두이노 Reed 자기 센서 제어

2019. 7. 9. 11:26드론

Reed 센서는 자석을 접근시키면 자성이 유도되어서 접점이 접촉되는 센서. 코일 혹은 영구자석에 의해 리드의 양쪽에 N극과 S극이 유도되어 자기력에 동작된다

 

int pinReed = 2;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(pinReed, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(pinReed)) {
Serial.println("Mini Reed OFF");
}
else {
Serial.println("Mini Reed ON");
}
delay(500);
}
view raw reed.c hosted with ❤ by GitHub