Introduction: Lazy Arduino Light Switch
Hi! Welcome to my second instructable! Second? Yes, indeed, second. Click here to view my first.
This time I decided to automate my light switch. Why? well, I'm an IT person, and I'm lazy, so why not!? The idea is that I'd like to be able to turn my lights on and of while laying in my bed. And of course I know there's things like Phillips Hue, but cmon, those are way to expensive. So I made an automated light switch myself, using the cheapest method I could find. An Arduino.
First (If you've seen my first instructable you know I love lists), i'll make some lists. Let's start with a MoSCoW.
The Things this light switch definitely must have are an IR-sensor for the remote, a servo to push my light switch and a mounting plate.
A thing that this lazy light switch should have is the ability to stay disconnected from my laptop. So a battery pack or wall adapter would be nice.
Something this project could have is time support. I'd like the light to automatically switch on at 5:30 every morning. Rise and Shine! And another function could be a motion sensor, so that when I enter my room, the light turns on.
What I would like to have is, besides the wall mount, a nice casing to cover up all the hardware.
Okay, now that we've got that list covered, let's start the second one. These are all the tools you'll need for this project
- A Lasercutter, Usually found in a Fablab.
- A 3D Printer, Usually found in a Fablab.
- Hot glue, Found in every DIY store.
- Soldering iron, Found in every DIY/Electronics store.
- A laptop or computer to write the Arduino code on (no fancy spec's needed here);
Nice! we've got that list done as well, getting annoyed allready? let's move on to the last one!
- ABS (That's the stuff that goes into 3D printers).
- Triplex, I used 3mm thick, but every thickness should work.
- An arduino, In this case, I used an Uno, But a Nano or Micro would be ideal.
- A Servo, I used this one.
- An IR sensor and remote, the one I used came with the Arduino Starters Kit.
- A 5V power adapter, I used one from my old phone(one of those outlet to usb adapters).
- An Arduino PIR motion Sensor. (info)
Okay, we're done with the boring lists(for now), Let's proceed to step 1!
Step 1: Drawing!
A good project starts with a lot of measuring and drawing, I took my notebook and ruler out, and wrote down everything I wanted.
After that, I drew the parts I needed. Check out the pictures to see what is drew.
this isn't the hardest step, but it is very important! I used my drawings as reference throughout the whole project, so I'll suggest making a few yourself.
Done? Nice! Let's proceed to step 2!
Step 2: Playing With Cardboard!
Allright, Now that we've got the drawings, we're able to make a first prototype. I'm making this first prototype to see if I got the measuring right and to check if my idea is possible.
To make this prototype, I used just a piece of cardboard and a break knife. First I drew the cutlines onto the cardboard, and then cut the pieces out. My cardboard prototype learned me that my measurings were a little incorrect, so I updated them and proceeded to the next step.
I highly recommend making a cardboard prototype. Not only to check your measurements, but also to get a good view of your project and to see if everything shapes like you want.
Got yourself a prototype? Let's move on to the next step!
Step 3: 3D Designing, Printing and All That Fancy Stuff.
Okay, now that you've got the drawings done, let's move on to the real stuff. 3D Printing.
The part we need to 3D print is a holder for the little servo, it needs to make sure the wings of the servo will hit the light switch. Of course it's possible to design your own holder, but unfortunately I'm not that creative. So I went to Thingiverse, Thingiverse is a great website for finding 3D models, so before you start the process of designing an own, take a look around here. The model I used is: servo-mount/holder.
All did was, download the file, load it into the 3D print software and smash that "PRINT" button.
Since it isn't a big model it only took me about 20 minutes before my print was done. So after that I took a piece of sanding paper and smoothen it.
Okay, Now that we've got the servo holder, we can move on to the next step!
Step 4: Playing With Them Lasers.
WOW LASERS, Yup, Too bad my friend, It's actually not as epic as it sounds, It works almost the same as 3D printing. Load your file, and hit that "PRINT" button.
But, of course, before we can print something, we'll need the files. This design was nowhere to be found on the internet, so I made it myself with adobe Illustrator. What you'll basically need is a plate, which fits over your light switch, and has a option to put your servo holder in. so I took my drawings (Told ya, You'll need them) and created a design.
The design I made fits perfectly on top of my light switch. The square hole is where the switch is, the round hole is for the power outlet, and beside them we've got a long slot, this is exactly the thickness of the servoholder.
I also needed a Wallmount to stick my Arduino to, this mount goes around my light switch and has a big open space for my Arduino.
After my designs were ready I loaded them into the LaserCutter and took my 3mm thick triplex. I let the machine do it's work, and BOOM, my product was done.
Got your servoholder, light switch plate and wallmount done? Nice! Let's proceed...
Step 5: Arduino Magic.
Okay, allright, sorry, it won't be magic.
In fact, It's really simple. First take out all your hardware, and make the listed(YES LIST) connections:
- Connect your Servo datapin(Usually white or yellow) to arduino pin 9.
- Connect your Servo 5Vpin(Usually red) to the arduino 5V.
- Connect your Servo groundpin(Usually black) to the arduino GND.
- Connect your IR datapin to arduino pin 3.
- Connect your IR 5V pin to the arduino 5V.
- Connect your IR groundpin to the arduino GND.
- Connect your PIR datapin to arduino pin 6.
- Connect your PIR groundpin to the arduino GND.
- Connect your PIR 5V pin to the arduino 5V
Okay, thats it! Now all we need to do is upload the code, which is quite simple, It reads the IR sensor, and when it reads a buttonpress it'll update the servo state, which turns to switch the light on or off. I also added a LED to signal the button press, The LED blinks the amount of times indicated by the button, so button 5 lets the LED blink 5 times. I also added the PIR motion sensor to sense if someone is entering the room. And last but not least I added the time functionality, So from now on, if the time passes 5 O'Clock in the morning the servo will update and the light will turn on.
okay, Got everything working? Let's Proceed...
Step 6: Assembling & Finish.
Okay, now that we've got the parts and our Arduino works it's time to assemble everything to one working piece. I put the servo into it's mount, tightened the screws and then glued the holder onto the Switchmount.
While the glue was drying I placed the wallmount and stuck my Arduino to it. When the glue was fully set, i fastened the switchmount to my light switch using double sided tape.
And that should be it. In the pictures at the intro you can see the whole construction. and If you've got any questions you can leave them in the comments. I'll be hanging around from time to time to help you solve your problems.
Thanks for looking at this instructable!