Controlling high power (or high number of) LED’s with an Arduino

A while ago I posted about my bench lights, and have gotten a number of request for schematics and code. I’ll gladly put the code up, but I also wanted to explain what I did so that others can create their own, or at least change my design up as they wish. The transistors I’m using are TIP122’s. You can find the data sheet here. They will switch a lot of power, but keep in mind, they need to have adequate cooling if you are going to push them hard. Always remember, fire = bad.

I covered the basic schematic for a few LED’s in the video above, but if you have any questions, feel free to post them in the comments and I will answer as quickly as I can.

You can download the original (controller with LCD and hard buttons) code here.

You can also download the newer (serial controlled – adjustable level) code here.

Just a note, I will be using Vimeo from now on, but I will still put all my videos on YouTube as well.

A word about open source hardware

Open Source Hardware

So, what is open source hardware and why should I be interested in it? Open source hardware is simply hardware that is released in the wild along with CAD files (PCB layout data), documentation, and hopefully a tutorial on how it is set up and works. The wiki page is located here. The Open Hardware Summit is here.

Now, I was skeptical about this when I first heard about it because I thought,”If I want to sell my stuff, why give away the information I worked on?” I mean after all, aren’t we supposed to design something, then patent, copyright, trademark, and lock it in a safe? Thats the way to keep it ours right? After all, I worked on it, and I should get all the credit and all the profit right? I’m not giving my stuff away! But then I started thinking…

I thought about myself buying hardware and how I yearn to know everything about it. When I found Adafruit Industries and Sparkfun, I thought, “Whoa! Sweet! Cool hardware and full documentation!” Did I first get the urge to download Ladyada’s board designs and have them made myself, cutting the seller out of the loop? Of course not. I mean, sure the option was there, but I would rather just purchase a kit with everything I need. This way, I get something in my hands a lot faster, tested, and documented for my hacking. The cost and time is just not worth me making my own.  Now, wouldn’t I want to offer the same thing to my customers? Of course I would, that’s what attracted me to buying from Adafruit in the first place.

When a maker/hacker buys something, it’s an entirely different attitude that a “regular” consumer. For the most part, a “regular” consumer wants to get the best deal on whatever they are buying, and they want it to “just work”. Yeah sure, us makers/hackers want the device to “just work” also, but we also want to know how and why it works. If we have full documentation, schematics, tutorials, and access to forums, we can fully understand what we own. And then once we understand it, we can fix, modify, hack it to our needs.

With all that said, I’m sold. I want to buy all my gadgets open source (if they are available), and want to offer the same back to the maker/hacker community. I have really learned a lot from good quality open source companies and the communities behind them, and would like to give back what I can.

There is a big move of DIY electronics right now. Some of us have been doing this for years, and others have just begun, but one thing is for sure, making and hacking is growing like mad. There is all kinds of great information available right now, as well as tools like the Arduino to get people started as well as develop new things. So don’t just read this, go make something!

EDIT: I just noticed that Ladyada has a great page on this!

Tic Tac Touch

OK, so I haven’t posted in a while because I have been working on some bigger projects, but yesterday, I took a two hour break and made a 2 player tic tac toe game. I did this with an Arduino and a 2.8″ touchshield from Adafruit.com. It’s pretty basic tic tac toe, and has score tracking, game logic (you can’t go twice in a row, and telling you if you win), and the ability to consume a chunk of time playing tic tac toe with my son. Below is the code, feel free to hack modify etc. If you play against a smart person (or yourself), you will have lots of Mosfet eye games! 🙂

Download the code here. (Arduino 22 .pde file)

 

Multiplexing for a 7 year old

I have been wanting to make a LED clock for sometime and can’t really believe I never have. So I rummaged through some parts and found some nice 4 segment LED displays. I found some code for a simple clock at nootropicdesign, and it did something pretty neat. It slowed down multiplexing so you could see it, then it would get faster until it appeared “on”. It was a good sketch, but I thought, it needs set buttons, a blinking colon, and a way to trigger the multiplex slow down trick with out restarting. (and resetting the clock!) So I made this little clock and it worked great.

This was a great way to show my 7 year old (who wrote his first Arduino sketch the other night) about multiplexing. A picture is worth 1,000 words right? Well, a hands on demo is worth even more than that. After explaining how it works, he totally understood.

Then I noticed I had, sitting on my bench, some Lexan laser cut, for those little Nokia LCD’s I love so much, that had a 4 segment LED display size hole in them. I made the clock and moved some pins around to free up 3 PWM pins for an RGB LED. Because it’s always good to have a full PWM controlled RGB LED, ya know, just in case. Thinking of programming the LED different colors/brightness according to sun position. I also remembered I have a few Dallas 1307’s.. Maybe tomorrow, it’s late right now, and besides I’m busy porting software for a Touch Shield I got. 🙂

If your new to multiplexing, it basically combines pins of LED’s and then through switching on only certain pins at a time, you can light only certain LED’s. If you were to apply power to more than 1 cathode and anode, you would get unwanted LED’s lighting. So how can this work? I have to light 14 LED’s just to display 1:00! What makes this work is you light one segment at a time. With a microcontroller, you can do this in an order and at a rate that’s fast enough that the human eye thinks that they are on solid. Most LED 4 digit displays found in microwaves, stoves, appliances, and VCR/DVD players are multiplexed. Its a great way to light a lot of LED’s with less pins than connecting each directly to the microcontroller. Below is a circuit diagram of the LED display I used. The link for the code is below as well, as always, hack away. 🙂 Detailed pinout for Arduino are in the code comments.

Multiplexing!

Get the code here. (Arduino 22 .pde file)

Schematic (Eagle file)

Schematic (png file)

Arduino Police LED Strobes!

OK, sometimes your brain gets a little fried on a project and you need to decompress a little right? That happened a little while ago, and here is the result. I have this awesome little 10th scale 40mph+ Losi stadium truck I play with now and then, and I have always wanted to do this. While the strobe modes are manually controlled with buttons, I have an urge to crack open my 2 channel transmitter and put a little ASK radio in there. Nothing like the element of surprise eh? What I really would like to do is make it autonomous. 🙂 Maybe later..

There are a few modes in the sketch, the video shows the first or “main” mode, but if you download the sketch the possibilities are endless to make calmer or even more obnoxious ones. I have noticed (not from my rear view mirror thankfully) the new LED bars on cop cars have a faster mode (almost like a boost mode) for high speed or high attention ares ie: intersections, but when they have someone pulled over, it is a slower pattern. Trust me, I know these things.

There are 20 (red and blue in: each of the headlights, tail lights, sides, and 4 red and blue in the light bar) “straw hat” style LED’s and they are driven by an Arduino and powered by a 3.7v Li-Po battery, you can buy them at adafruit.com. There is not an actual Arduino inside, just a 328 programmed with the Arduino IDE. It’s way cheeper that way. (I tend to put 328 chips in a lot of stuff) Below is the sketch for your hacking. A really good tutorial on “LED blinky modes” can be found from Lady Ada here. I actually learned a lot from this tutorial series a while ago, but still reference it from time to time. Good stuff.

Click the picture to see the full image of the truck (4.7MB) You can see how dirty it is.. :\

Download the sketch here. (Arduino .pde file)