Hi everyone! I am creating a home security system for my capstone project. I am using KY-021 reed switches as door and window sensors. As I was trying to make it work, the two-reed switch sends the same data even though I only triggered 1 switch.
here is the code:
#define ReedSwitch01 2
#define ReedSwitch02 7
void setup() {
// put your setup code here, to run once:
pinMode(ReedSwitch01, INPUT);
pinMode(ReedSwitch02, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if(millis() % 2000 == 0){
Serial.println("Switch 01:" + String(digitalRead(ReedSwitch01)));
Serial.println("Switch 02:" + String(digitalRead(ReedSwitch02)));
}
}