Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Energy-saving devices are crucial in today's world to reduce energy consumption and promote sustainability. These devices help in minimizing the wastage of electricity by automating the control of electrical appliances. With the help of Arduino, we can create efficient energy-saving systems that are both cost-effective and easy to implement. This article will guide you through creating an energy-saving device using Arduino, focusing on its importance and the necessary adjustments to align it with the Arduino environment.
Project: The project involves creating an automatic light control system using Arduino. The objective is to turn off the lights when no one is present in the room, thereby saving energy. The system will use a PIR (Passive Infrared) sensor to detect motion and a relay module to control the light. When the PIR sensor detects motion, it will send a signal to the Arduino, which will then activate the relay to turn on the light. If no motion is detected for a specified period, the Arduino will deactivate the relay, turning off the light.
Components List:
Examples:
// Define the pins for the PIR sensor and the relay module
const int pirPin = 2; // PIR sensor output pin
const int relayPin = 3; // Relay module control pin
// Variable to store the PIR sensor status
int pirStatus = 0;
void setup() {
// Initialize the serial communication
Serial.begin(9600);
// Set the PIR sensor pin as input
pinMode(pirPin, INPUT);
// Set the relay module pin as output
pinMode(relayPin, OUTPUT);
// Initially turn off the relay
digitalWrite(relayPin, LOW);
}
void loop() {
// Read the status of the PIR sensor
pirStatus = digitalRead(pirPin);
// Check if motion is detected
if (pirStatus == HIGH) {
// Motion detected, turn on the relay
digitalWrite(relayPin, HIGH);
Serial.println("Motion detected! Light ON.");
} else {
// No motion detected, turn off the relay
digitalWrite(relayPin, LOW);
Serial.println("No motion. Light OFF.");
}
// Add a small delay to avoid bouncing
delay(1000);
}
Explanation: