The automatic shelter project is designed to provide a convenient and efficient way to protect individuals from sunlight. By utilizing a photoresistor sensor, the shelter automatically activates when exposed to light. In this blog post, we’ll delve into the hardware components, the circuit diagram, and the Arduino code necessary to build this innovative shelter.
Hardware Required
To create the automatic shelter, gather the following components:
- Arduino Uno R3: The brain of our project.
- Resistor: Used in the circuit.
- Jumper Wires: For connecting components.
- Servo Motor: Controls the shelter movement.
- Photoresistor: Detects sunlight.
Circuit Diagram
Arduino Code
#include <Servo.h>
// Declare Servo Motor
Servo servomotor;
const int photoresistor = A0;
const int motor = 9;
int photoresistorValue = 0;
int outputValue = 0;
float nice = 0.09;
float myValue;
void setup() {
Serial.begin(9600);
servomotor.attach(motor);
}
void loop() {
photoresistorValue = analogRead(photoresistor);
myValue = float(map(photoresistorValue, 0, 100, 0, 180));
outputValue += int(myValue - outputValue) * nice;
Serial.print("Sensor = ");
Serial.print(photoresistorValue);
Serial.print("\t Output = ");
Serial.println(outputValue);
servomotor.write(outputValue);
delay(10);
if (photoresistorValue > 900) {
outputValue = 160;
}
if (photoresistorValue > 700) {
outputValue = 120;
}
}
Precautions
Here are some important precautions to keep in mind during the project:
- Proper Connections: Ensure that all connections are made correctly.
- Case Sensitivity: Remember that Arduino code is case-sensitive.
- Color-Coded Wires: Use different and appropriate colors for your wires.
- Resistors: Don’t forget to use resistors for sensors and LEDs.
By following these guidelines, you’ll be well on your way to creating an automatic shelter that responds to sunlight effectively. Happy building! 🌞🏠