Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Creating a door/window opening detection system with Arduino is a practical project that can enhance home security or automate home environments. This system can be built using basic components such as magnetic reed switches or infrared sensors, along with an Arduino board. Here's a step-by-step guide to building this system.
Wiring the Components:
Arduino Code: Here's a simple Arduino sketch to detect when a door or window is opened:
const int reedSwitchPin = 2; // Pin connected to the reed switch
const int ledPin = 13; // Pin connected to the LED
const int buzzerPin = 3; // Pin connected to the buzzer
void setup() {
pinMode(reedSwitchPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensorState = digitalRead(reedSwitchPin);
if (sensorState == HIGH) {
// Door/window is open
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
Serial.println("Door/Window is OPEN!");
} else {
// Door/window is closed
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
Serial.println("Door/Window is CLOSED.");
}
delay(500); // Delay for debounce
}
Testing the System:
This project is a straightforward introduction to using sensors with Arduino and can be expanded with wireless modules to send alerts to a smartphone or a computer.