Introduction: Home Automation: Drapes
Hate having to manually open and close your drapes? Hate getting back from work/school and your room is dark and dreary? Do you want curtains that open and close themselves? Then you need Dr. Drape!
Dr. Drape is an easy DIY project using an Arduino and servo to open and close your drapes at the tap of a button or on an automated schedule. The code included in this tutorial responds to your button press to open or close the drapes, as well as opens them at 10 am Monday - Friday.
Difficulty is easy, and anyone with some Arduino experience should be able to follow! This is my first instructable, so let me know if I should make any changes. Otherwise grab your soldering iron and C programming book, we're gonna move some drapes!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Before You Begin...
Attached are some pictures of my window before I began. There is a few inches of space between the wall and the curtain to fit the Arduino, motor, and pulley system so that they do not stick out. On the left side we are just going to mount a pulley that will hold the cord, while the right will have the wheel, motor, and Arduino.
Arduino Power Supply: http://www.amazon.com/gp/product/B00BWA48AA/ref=oh...
Arduino Programming Cable (if you don't have one): http://www.amazon.com/gp/product/B001TH7GUA/ref=oh...
Cord to pull curtain (at least 2x the width of your window)
Command Strips for attaching stuff to the walls
Pulley for side opposite the Arduino
3D Printer (I used this to print the mount, in the likely even you don't have access to one you would have to find a workaround)
Screwdrivers/other basic tools
Step 2: Continuous Rotation Servo
Having the benefit of hindsight, you should probably order a servo that has continuous rotation out of the box. I forgot to check when ordering, so the servo I ordered did not. However, it is possible to modify the servo so it can rotate 360 freely. The tutorial I followed to do this is here: http://flitetest.com/articles/easy-9g-continuous-r...
For the servo listed in the parts list here, I had to cut out a plastic block that prevented the servo from over-rotating as well as cut off the potentiometer and solder on two 2.2k ohm resistors. At this point, the servo was no longer "centered" around 90 being neutral, 0 being left, and 180 being right. I had to go through and test lots of different options, and had to use Servo.writeMicroseconds() instead of just Servo.write(). My values I found were 700 for left, 1424 for neutral, and 2300 for right.
After making these modifications to the servo, the resistors stick out of the side of the servo body, for which I recommend you cut a hole in the plastic body to fit these through. For the 3D printed mount I made, I also made a hole for the 3-wire servo connect to thread through the side. This way, I could leave just 1 side of the servo exposed on the mount.
Step 3: The Servo Wheel
The wheel I attached to the servo I just found lying around in a parts bin, so I cannot tell you what it actually is. Just make sure your wheel is small enough that the torque of your servo can still handle the curtain. I would also recommend you have a hole in the middle of it so you can attack your servo arm before attaching the arms to the servo (like in the pictures above).
Step 4: (Optional) Prototyping the Circuit
Before actually mounting everything together, it can be a good idea to make sure that all your electronics work. Here is a picture of me testing my button.
You should test your board with the servo as well. You can pick through the code attached at the end of the tutorial to find out how to operate the servo and detect button presses.
Step 5: The Mount
Next you have to figure out a way to mount your assembly to the wall. I used FreeCAD (http://www.freecadweb.org/) to draft my designs. You can look at these designs in the attached .fcstd file or view them as an exported mount.stl (the format the 3D printer took). Please note if you want to take this approach that the holes for the arduino are slightly off. You can fit either the NW and SE screws or the SW and NE screws, but not both. I found that two screws were sufficient, but if you want perfection you will have to remeasure the board and modify the model in FreeCAD yourself.
Step 6: Wiring Diagram and Putting It All Together
The first picture attached is a (poorly drawn in paint) wiring diagram for how to setup your project.
The button has one terminal going to digital ground and the other going to digital input 2.
The Servo has black to ground, red to 5V supply, and white to PWM pin 9.
It might be easier to just look at the completed wiring (picture 2) than the wiring diagram. After everything is wired up, grab your screwdrivers and some superglue and just a dash of imagination and put everything together. Congrats! You're almost done.
Step 7: Software
I attached all three of the .ino files I used to program Dr. Drape. You can obviously modify these files to change the precise behavior of your robot, or just leave them the same and your robot should behave exactly like mine.
The code should be largely self-explanatory, but is a bit convoluted to use.
When you first turn on the bot, you have to set the date and time. This is done by pressing the button 0-6 times to set the day of the week.
After pressing the button the desired number of times, hold a long press (at least 1 second), to move on to setting the hours. Press the button 0 - 23 times for 24 HOUR military time.
Minutes are a bit more complicated: because I did not want to have to press the button 59 times in some cases, you press the button for the 10's place and then for the 1's place. For example, this is how you input various minutes:
0: long press, long press
01: long press, short press, long press
10: short press, long press, long press
59: 5x short press, long press, 9x short press
Seconds are just set at 0.
Provided you do not modify the code, your robot is done being set up. If you press the button, it will open the drapes first. DO NOT MESS THIS UP!!! Otherwise your robot will pull the drapes in a way they cannot go, and might damage your servo. The code as I have it is set up to begin with the curtain closed. This might be reversed with the way you connect your cord to your curtain, so it is best to check before you actually attach the cord.
You can now press the button to toggle your curtain state. If it is open, pressing it closes it, and vice versa. Pressing the button while the curtain is moving will trigger the emergency stop, and will kill power to the servo and stop the program. You will have to restart the Arduino and re-enter the current date/time to use the button again.
With this code, Dr. Drape will automatically open your curtain Monday through Friday at 10 am. You can easily go into the file and change some values to change the behavior. Dr. Drape will only open the curtain, it will not close the curtain (even if it is open at 10 am, at which point it will do nothing).
Step 8: Wrapping Up
Your final project should be a nice and discreet addition to your room. If you have any questions, don't hesitate to message me and I will help you out (especially if you need help modifying the code). Otherwise, enjoy!