Introduction: Blinduino - Automated Blinds Via Arduino
In this Instructable you will learn how to to use a DC motor, an Arduino microcontroller, and a few other electronic knick-knacks (unfortunately for some of you, I had access to and used a 3D printer in a pretty important way) to automate the control (via your ball-chain) of your blinds. My initial inspiration was to track the sun using a photodiode, but there are a great many more things you can do with this setup!
For this project, general experience (nothing too fancy) with electronics, wiring, knowing what a diode is, etc. is recommended. Similarly, a surface knowledge of how to use an Arduino should be sufficient. The main requirement for the DIY-er embarking on this project is a great deal of patience and love for troubleshooting. If everything goes right on the first try, you probably aren't solving an interesting problem.
Cost: ~$35 (not including 3D printer... but we'll get to that)
Step 1: Materials
Things you'll need: -Arduino microcontroller (I used a Leonardo)
-Computer to tell Arduino what to do
-L298N (Full-bridge motor driver) [There are simpler alternatives, but this is what was available to me]
-4 fast recovery diodes (I used 1N4148)
-lots and lots of wires
-a 12V DC power supply (anything providing over 7V will suffice)
-a DC motor
-a ball chain pulley (I 3D printed this part using wulfdesign's design http://www.thingiverse.com/thing:6663)
As you can see, there is some flexibility in what you use. Creativity is a beautiful thing.
Step 2: Philosophy of the Setup
The idea of what we're going to do is as follows: we take a DC motor and attach a pulley fitted for the ball chain of our blinds to the end. Using a bridge circuit, we allow our motor to move bidirectionally (because a project that could only open blinds would be boring) according to input from our Arduino. Then we have the fun stuff. Our photodiode will tell our Arduino how much light is at a certain part of whatever room in which our project is located, so, using clever a Arduino routine, we can find a blind setting with maximum brightness (in effect tracking the sun).
Step 3: The Circuit
Luckily for us, the L298N datasheet has an example circuit called "bidirectional DC motor control"! The picture may look rather complicated, so I'll do some explaining:
-Since our L298N actually has more components than we need, we will not be using all of the chip's pins.
-Pin 4 receives the supply voltage for our motor: you might want to dial this down from the recommended 12 Volts (my motor spins pretty darn fast at 12V) so you have a little bit of precise control over your blinds.
-Between pin 15 and ground, the datasheet recommends you put a "sense resistor" to limit the current through the motor. In my case, however, limiting current wasn't an issue, so you're fine directly wiring pin 15 to ground.
-Pin 8 is connected directly to ground.
-Pin 9 is connected to Vss, the supply voltage for the component's logic. Give this pin 5V (you can do this with your Arduino). The capacitor is unnecessary for our purposes.
-Pins 13 and 14 are the bridge's outputs; these pins go, with the helps of our diodes, to our motor's inputs.
The logic of this circuit deserves special attention. Pins 10, 11, and 12 dictate what goes on with the motor. That information is contained in the table on this page. High and low refer to TTL outputs. We'll send 5V from our Arduino to mean high and 0V from our Arduino to mean low. All grounds in the circuit should thus be connected.
Step 4: An Alternative
If the previous circuit makes your knees weak, you might want to check out an alternative about which nothinglabs has published an Instructable at https://www.instructables.com/id/Super-Easy-Reversible-Motor-Control-for-Arduino-/ . At a certain point in my troubleshooting, I was convinced that my L298N has burnt out and I wouldn't be able to find another one, so I spent a fair amount of time looking into/soldering the nothinglabs design. In my opinion, the nothinglabs method might even be more fun.
Step 5: Mechanical Considerations
As previously mentioned, I had the good fortune of being able to 3D print my pulley using the design from http://www.thingiverse.com/thing:6663. Here's where you have to consider the specifics of your own particular setup. The grooves ought to be big enough that your ball chain will sink in, but not so large that they don't "grab on." Similarly, we need to consider what size our motor's shaft is. In my case, the pulley's hole was slightly too large for my motor's shaft, so I, recognizing that the pulley was made out of plastic, forced a screw through one of the sides to ensure a tight fit.
The pulley itself is one of the more wonky elements of my prototype; it sits pretty far from level on the motor and makes ball chain slippage a serious concern. Given more time, the first improvement I would make would be to print a pulley better suited to my particular setup. Similarly, mounting the motor itself is a pretty relevant issue. I used stacks of textbooks and duct tape. There are clearly better options than this, but all of those would have involved me receiving some sort of fine for doing unholy things to my dorm room.
The video shows some of the slippage in action.
Step 6: Routines (or: Where the Fun Begins)
At this point, we've done most of the leg work. Now we can begin to develop exciting uses for our project. This is where the Arduino becomes more involved. We attach our photodiode (along with a large resistor [something on the order of 10K] to prevent our Arduino from being fried by too much current) to one of the analog inputs of the Arduino. What follows is a sample Arduino program called "blinds" which uses a "dither" function to find relative maxima of light intensity as a function of blind angle every 30 minutes. Note that I am using the Arduino Leonardo's PWM pins 9, 10, and 5 to control the bridge's logic, and that restime should depend on the specifics of your setup (e.g. motor voltage, how much turning it takes to open your blinds, etc.).
boolean left = false;
boolean right = false;
left = true;
right = true;
I'd like to eventually get my mounting/mechanical issues sorted out enough to record a time-lapse video of this program running throughout the day. If I ever get that to work, I'll probably put that video right here.
Step 7: Congratulations!
You've made it to the end. If you embark on the journey of building this project, please leave a comment, especially if you're having issues. In the end, your creativity is the only limit on what blinds-related things you can do with this system. Some examples/ideas (in increasing order of ridiculousness/fun) are:
-Alarm clock mode: it's nice to wake up to the sun.
-Lockdown mode: add a physical button which immediately closes your blinds.
-S.O.S. mode: flash the letters "SOS" in morse code, for the dramatic DIY-ers out there.
-Haunted house mode: randomized periodic motion to convice your guests of the presence of ghosts.
Alternatively, I've always wondered about using the bidirectional DC motor control to constitute a primitive seismograph (using a physical pencil).
That's it! Go forth and prosper.
We have a be nice policy.
Please be positive and constructive.