Introduction
In this article, I will walk you through the process of building a simple do-it-yourself (DIY) electronic device that can solve a common problem that most people encounter in their daily lives. With just a few common components and basic skills, you can make a useful gadget in no time.
Identifying a Problem to Solve
The first step is to identify a common frustration or issue that could be solved with a simple electronic device. Here are some potential problems to consider:
- Forgetting to turn off lights and appliances
- Losing important small items like keys or wallets
- Difficulty seeing in dark areas like closets or under furniture
- Limited visibility when backing up a car
- Forgetting to take medication on time
I decided to focus on the issue of forgetting to turn off lights and appliances. This wastes electricity and money, so a device that can automatically shut off lights or electronics after a set period of inactivity would be very handy.
Selecting the Right Electronic Components
Now that I've identified the problem, it's time to figure out what electronic components I'll need to build the device. Here are the main items:
- Microcontroller - This is essentially a small computer that will control the logic and input/output. An Arduino Uno is a good choice for beginners.
- Motion sensor - I'll use a passive infrared (PIR) sensor to detect movement and inactivity. The HC-SR501 is inexpensive but effective.
- Relay - To turn lights and appliances on and off, I need a relay that the microcontroller can switch. The SRD-05VDC-SL-C should do the trick.
- Power supply - To power the Arduino and other components, I'll use a standard phone charger style 5V DC power supply.
Prototyping on a Breadboard
With my components selected, it's time to build the circuit. I'll first prototype it on a solderless breadboard so I can test the functionality and make modifications easily.
Here are the steps I followed to construct the prototype circuit on the breadboard:
- Connect the 5V and GND pins from the Arduino to power and ground bus rows on the breadboard.
- Insert the PIR motion sensor on the breadboard and connect the VCC, GND, and OUT pins.
- Connect the IN pin on the relay module to a digital I/O pin on the Arduino.
- Connect the VCC and GND from the relay to power and ground.
- Connect the power supply to the Arduino and breadboard power rails.
At this point, I have a simple circuit that can detect motion with the PIR sensor and activate the relay based on a program I'll load onto the Arduino.
Programming the Arduino
Now for the brains of the operation - the Arduino program code. I wrote the following program to accomplish the automation logic I want:
```cpp
const int pirPin = 3; //input from PIR sensor
const int relayPin = 4; //output to relay
void setup() {
pinMode(pirPin, INPUT);
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH); //turn on relay initially
}
void loop(){
if(digitalRead(pirPin) == LOW){ //if no motion
digitalWrite(relayPin, LOW); //turn off relay after 5 seconds
delay(5000);
}
else{
digitalWrite(relayPin, HIGH); //turn on if motion detected
}
}
```
This checks the PIR sensor continuously in a loop. If no motion is detected for 5 seconds, it turns the relay and connected device off. But it immediately turns back on when motion is detected again.
Assembling the Final Device
With the circuit functioning correctly on the breadboard, I just need to assemble it into a permanent device. I soldered the components onto a prototype perfboard with some headers for the Arduino. I added a hobby enclosure, switches, and a DC power jack.
Some tips for assembly:
- Use ribbon cables between the Arduino and perfboard for easy development
- Hot glue sensitive components in place to prevent shaking/shorts
- Label wires, switches, and indicators clearly
And that's it! I now have a working DIY device that can automatically shut off lights and appliances to save power when I leave a room. Pretty handy for such a simple gadget!
Potential Improvements and Iterations
While functional, there are some ways this device could be enhanced:
- Add a real-time clock module to have more control over on/off times
- Incorporate a photoresistor to disable automation in daylight
- Use a latching relay to avoid constant power drain
- Add a buzzer or indicator LED for user feedback
The great thing about DIY electronics is that it's easy to test ideas and iterate on a basic concept. I may try some of these upgrades in the future!
So in summary, with just a few common components, basic DIY skills, and a simple Arduino program, I was able to create an automated power-saving device. Let me know if you build your own version or have ideas for other useful electronic gadgets!