Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Door/Window Detection with Arduino
Introduction: Door/Window detection is an essential component of home automation and security systems. By using Arduino, we can easily create a project that detects the status of doors or windows and triggers actions based on their open or closed state. This article will guide you through the process of creating a door/window detection project using Arduino, providing example codes and a list of components required for the project.
Project: The project aims to create a door/window detection system that can monitor the open or closed state of doors or windows. The system will use magnetic reed switches to detect the position of the door/window and provide real-time feedback.
Components Required:
Example Code: Below is an example code that demonstrates how to detect the open or closed state of a door/window using Arduino:
// Door/Window Detection with Arduino
const int reedSwitchPin = 2; // Pin connected to the magnetic reed switch
const int ledPin = 13; // Pin connected to the LED for visual feedback
void setup() {
pinMode(reedSwitchPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int doorState = digitalRead(reedSwitchPin);
if (doorState == HIGH) {
digitalWrite(ledPin, HIGH);
Serial.println("Door/Window is closed");
} else {
digitalWrite(ledPin, LOW);
Serial.println("Door/Window is open");
}
delay(500); // Adjust the delay as per your requirement
}
Explanation: