Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Home Automation Projects
Introduction: Home automation is becoming increasingly popular as it offers convenience, energy efficiency, and improved security. In this article, we will explore the world of home automation projects using Arduino. We will provide examples of codes and a list of components required for each project.
Project: Automated Lights Control System Objective: To create a system that automatically controls the lights in a room based on occupancy. Functionality:
List of Components:
Examples: Example 1: Motion Sensor Activation Code:
int motionPin = 2; // Motion sensor connected to digital pin 2 int relayPin = 3; // Relay module connected to digital pin 3
void setup() { pinMode(motionPin, INPUT); pinMode(relayPin, OUTPUT); }
void loop() { if (digitalRead(motionPin) == HIGH) { digitalWrite(relayPin, HIGH); // Turn on the lights } else { digitalWrite(relayPin, LOW); // Turn off the lights } }
Example 2: Manual Control Code:
int motionPin = 2; // Motion sensor connected to digital pin 2 int relayPin = 3; // Relay module connected to digital pin 3 int switchPin = 4; // Push button switch connected to digital pin 4
void setup() { pinMode(motionPin, INPUT); pinMode(relayPin, OUTPUT); pinMode(switchPin, INPUT_PULLUP); }
void loop() { if (digitalRead(motionPin) == HIGH || digitalRead(switchPin) == LOW) { digitalWrite(relayPin, HIGH); // Turn on the lights } else { digitalWrite(relayPin, LOW); // Turn off the lights } }