Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Importance and Utility of Door/Window Detection
Door/Window detection is a crucial aspect of home security and automation systems. By implementing a door/window detection system, homeowners can monitor and control the status of their doors and windows remotely. This allows for enhanced security, energy efficiency, and convenience. For example, the system can send notifications to the homeowner's smartphone if a door or window is left open, allowing them to take appropriate action. Additionally, the system can be integrated with other home automation devices, such as smart thermostats, to optimize energy usage based on the open/closed status of doors and windows.
Project: Door/Window Detection System
The project aims to create a door/window detection system using Arduino. The system will consist of magnetic reed switches, an Arduino board, and an LCD display. The objectives of the project are:
List of Components:
Examples:
Example 1: Door/Window Status Display
#include <LiquidCrystal_I2C.h>
// Initialize the LCD display
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address and dimensions
// Define the pin for the magnetic reed switch
const int doorSwitchPin = 2;
void setup() {
// Initialize the LCD display
lcd.begin(16, 2);
lcd.print("Door/Window");
lcd.setCursor(0, 1);
lcd.print("Status: Closed");
// Set the door switch pin as input
pinMode(doorSwitchPin, INPUT);
}
void loop() {
// Read the status of the door switch
int doorStatus = digitalRead(doorSwitchPin);
// Update the LCD display based on the door status
lcd.setCursor(0, 1);
if (doorStatus == HIGH) {
lcd.print("Status: Open ");
} else {
lcd.print("Status: Closed");
}
delay(500);
}
Example 2: Door/Window Notification
#include <Wire.h>
#include <Adafruit_SSD1306.h>
// Initialize the OLED display
Adafruit_SSD1306 display(128, 64, &Wire, -1);
// Define the pin for the magnetic reed switch
const int doorSwitchPin = 2;
void setup() {
// Initialize the OLED display
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
// Set the door switch pin as input
pinMode(doorSwitchPin, INPUT);
}
void loop() {
// Read the status of the door switch
int doorStatus = digitalRead(doorSwitchPin);
// Display the door status on the OLED display
display.clearDisplay();
display.setCursor(0, 0);
if (doorStatus == HIGH) {
display.println("Door: Open");
// Send notification to smartphone
// Code for notification goes here
} else {
display.println("Door: Closed");
}
display.display();
delay(500);
}