Home Automation Project: Time-Automated Lamp
by huughratdar in Circuits > Microcontrollers
93 Views, 0 Favorites, 0 Comments
Home Automation Project: Time-Automated Lamp
Do you have trouble waking up in the morning? Do you hate sleeping with the lights on? Are you Muslim? I will introduce a time-automated lamp! The lamp is triggered by the input of an hour, minute, and second flashed from the code, mainly 6 am. I got the idea from my and my family's lack of ability to wake up for the morning prayer, fajr, and work or school.
Supplies
- Cardboard
- Tape
- 2 tripe A batteries
- Argon
- Breadboard
- Wires
- Servo
- Hot glue gun
- Mobile power bank
- USB micro cable
- Touch-sensor lamp
- X-Acto knife
Setting Up Your Breadboard
Attach argon, wires, and servo to the breadboard.
Firmware
Servo myServo;
void setup()
{
myServo.attach(2);
myServo.write(170);
Time.zone(-5);
}
void loop()
{
if (Time.hour() == 6){
if (Time.minute()== 01){
if(Time.second()==1){
Time.isPM();
for(int pos = 10; pos <= 170; pos++){
myServo.write(10);
delay(20);
}
}
}
if (Time.minute()==10){
if(Time.second()==1){
Time.isPM();
for(int pos=170; pos >=10; pos--){
myServo.write(170);
delay(20);
}
}
}
}
}
Attaching the Batteries and Power Source
The lamp I have is the Amazon White Crown LED Desk Lamp Dimmable Table Lamp so it was touch-activated which is why my design was the following. If your lamp is turned on with a switch or button, you may have to adjust what your servo will move instead of batteries. So, for a touch-activated lamp:
First, use the X-Acto knife to cut out 1 square piece and 2 rectangular pieces of the same size. Hot glue the square piece with 2 of the rectangular pieces so they form a L-shape. After, hot glue the servo fan to the bottom rectangular piece. Look at the picture for visual clarification.
Then take the rectangular piece sticking out and use the X-Acto knife to cut a small plus sign at the ends of the pieces so that the triple A battery can be pushed down and held in place. Make sure to push down the battery so the negative end is touching the desk or facing down. Use tape to secure the battery in place.
Clip the servo onto its fan and connect the USB micro cable to the argon.
You're Good to Go :)
Now your room will light up each morning and you should have one less excuse for missing fajr prayer.