Pulse Width Modulation With Microcontrollers

Those following the ProtoStack tutorials will be happy to hear that there is a new installment which explains Pulse Width Modulation. If you’ve never heard of PWM before, it’s a method of generating a signal that is logic 1 for a portion of the time and logic 0 for the remainder of the time. It is the most commonly used method for dimming an LED, and that’s [Daniel’s] example in this tutorial. But you’ll also find it used in many other applications such as servo motor control and piezo speaker control.

[Daniel] starts off with a brief explanation of duty cycle, then moves on to some examples of hardware and software PWM. Many of the AVR microcontrollers have a hardware PWM feature that allows you to configure a pin that toggles based on a target timer value. This is demonstrated using an ATmega168, but a method of using interrupts and your own code is also covered in case you don’t have a hardware PWM pin available.

Awesome Custom Disco Basement

led_shelves

[Evan] is one of those neighbors you only wish you had.

His neighbors were renovating their basement for use as home theater, and he stopped by to check out how things were coming along. While there, he suggested they add some LED lighting to their shelving unit to make them pop. His neighbors were game, so he sourced some cheap RGB LEDs online and began working on the circuits and firmware needed to control the lights. His neighbors wrote some custom software that interfaces with iTunes to create a neat visualization in the shelving unit whenever music is played.

Once everything was complete, his neighbors informed him that they wanted an additional 20 overhead can lights and a set of 4 wall sconces wired up as well. Needless to say he was pretty excited, so he got busy wiring up the remainder of the basement.

He pushed the installation’s PIC microcontroller about as far as he possibly could, resulting in the awesome show seen in the video below.

Needless to say, it’s pretty impressive, though we wish we could have a peek at the code used to run everything. Wink, wink, nudge, nudge.

Continue reading “Awesome Custom Disco Basement”

Dimming Control For An Ikea Solar Desk Lamp

[Frank] decided to augment his desk lamp’s features by adding dimming controls (translated). Since the light source is a triad of LEDs the best method of dimming their intensity is to use Pulse Width Modulation. That’s the method that he went with, and luckily the SUNNAN lamp from Ikea which he’s using as the donor for the project has just enough room to squeeze in the parts necessary for this hack.

You need two main bits to use PWM with a lamp like this; a microcontroller (or possibly a timer chip like the 555) and a transistor to protect that chip from the current necessary to run the LEDs at full brightness. [Frank] went with an ATtiny13 and a 2N2222 transistor, both quite common and very inexpensive (you can even pull the microcontroller from a light bulb if you know where to look). Two buttons were added to the top of the lamp base which allow for up and down controls. There’s even an SOS function which is triggered by pressing both buttons at the same time. [Frank’s] happy to show off the completed project in the clip after the break.

Continue reading “Dimming Control For An Ikea Solar Desk Lamp”

Optimizing Code For PWM Efficiency

For some projects, it’s okay to have a microcontroller twiddling it’s thumbs most of the time. When a project requires the cpu to do just one thing over and over, there’s no loss with inefficient code – it either works or it doesn’t. However, if a project requires a microcontroller to do several things at once, like reading sensors, dimming LEDs, and writing serial data out, cpu utilization can become an issue. [Robert] wasn’t happy with the code he used to control a string of LEDs, so he rewrote his code. With the old implementation, [Robert]’s code used 60% of the cpu time. With the new and improved code, the cpu was only busy 8% of the time.

The code works by using a hardware timer to trigger an interrupt. After calculating the next time it should run again, and changing the state of the data line, the code just sits quietly until it’s needed again.

It’s not a pretty hack, or even one you can hold in your hands, but [Robert]’s determination in getting a μC to do what he wants is admirable.

Laptop Touchpad-based LED Lighting Control

touchpad_lighting

[Dave] needed some extra light above his desk/workbench area and decided to wire up some RGB LED light strips to brighten the place up a bit. He wasn’t content with using a standard switch to toggle them on and off, and after some brainstorming, he decided to build a capacitive touch circuit using a pair of copper tubes mounted in a project box. Just as he was putting the finishing touches on his switch, he saw a project online where a Synaptics touchpad was used in conjunction with an Arduino for lighting control. The copper tube switch was pitched, and he got busy working with his Arduino.

When connected to an Arduino, the touchpads can be used in two modes – relative and absolute. Relative mode is familiar to most people because it is used to guide the mouse cursor around on a laptop’s screen. Absolute mode however, relays coordinate information back to the Arduino, allowing the user to map specific areas of the pad to specific functions. [Dave] enabled his touchpad to use absolute mode, and mapped a handful of different functions on the Arduino. He can now fade his lights on and off or light the room on a timer, as well as use a sliding function to tweak the LEDs’ brightness.

It’s a neat, yet simple hack and a great way to repurpose old laptop touchpads.

Continue reading for a quick demo video he put together, and swing by his site if you want to take a look at the source code he used to get this working.

Continue reading “Laptop Touchpad-based LED Lighting Control”

Third Time’s A Charm – 512 LED Cube Kicks It Up A Notch With RGB LEDs

rgb_led_cube

In the comments section of our 512-LED cube post from the other day, several people suggested that to take the project up a notch, building a similar cube using RGB LEDS was the next logical step. It seems that Hack-a-Day reader [vespine] was way ahead of the curve, as he sent us the build details of his 8x8x8 RGB cube shortly after the other story was published.

His cube, which was finished earlier this year, uses 512 10mm RGB LEDs, arranged on top of a simple elevated stand. The stand conceals all of the circuitry he uses to control the cube, the centerpiece of which is a PIC32 MCU. A dozen TLC5940 16-channel PWM drivers are used alongside the PIC in order to adjust the color output of the LEDs, each of which can be addressed and colored individually.

The end result is just about as amazing as you would imagine. He has created several quick demonstration animations, which you can view in the video below. Be sure to stop by his site to see all of his build details – there’s quite a lot there.

Continue reading “Third Time’s A Charm – 512 LED Cube Kicks It Up A Notch With RGB LEDs”

PWM-controlled LED Display Is Truly A Gift From The Heart

led_heart_panel

Instructables user [Simon] admits he addicted to electronics. Lucky for him, his wife of 15 years is pretty cool with, or at least tolerant of his need to fiddle with anything that plugs in. As a gift for their wedding anniversary, he decided it would be neat to combine his love for his wife with his love for electronics. The result is the the RGB LED “Love Heart” you see above. He built an RGB LED circuit controlled by a PIC12F683 microcontroller, which shines into a hand-etched plexi-glass panel.

The LED color is controlled using PWM, as you would expect. What you might not expect however, is the lengths [Simon] would travel to ensure nearly perfect color and brightness matching across the 5 LEDs he used in his project. Since RGB LEDs do not have a uniform output brightness, he used a Lux meter to precisely measure the white balance of each LED. He then plotted the results in Excel before coding the PWM driver. Now that’s devotion! Once the LEDs were settled, he went about constructing the rest of the LED panel.

If you are interested in building one for your sweetheart, [Simon] has you covered – he provides all of the schematics, templates, and source code required to get the job done.

Continue reading to see a video of his heart panel in action.

Continue reading “PWM-controlled LED Display Is Truly A Gift From The Heart”