Controlling Lots of Outputs from a Microcontroller

Making LED displays is fun. There are a a few tools that get used all the time, from row-column scanning to LED driver chips to multplexers and shift registers. This tutorial discusses some of the more popular methods for controlling large amounts of LEDs from a microcontroller, including their various strengths and weaknesses, and how they work. For more on this subject see chapter 14 of “Physical Computing“, where Dan O’Sullivan and I discussed it in more depth.  I’ll also include some notes on how to apply these ideas to controlling multiple motors or other high-current loads.

Most microcontroller modules have a limited number of outputs. Even if you use the analog inputs as digital I/O, there are only 19 pins on an Arduino, for example. That’s a fairly typical number for an 8-bit controller, and it seems not nearly enough if you want to control, say, 100 LEDs or more.  There are a couple ways around this problem.  Without adding any additional hardware, you can make a matrix of your LEDs and control them using row-column scanning.  If you want discrete analog control over one output at a time, you can use a multiplexer. For digital control over multiple pins, you could use an addressable latch or a shift register. If you need pseudo-analog control over multiple pins, you could use a PWM driver.  There are also several LED driver chips that are designed specifically to control groups of LEDS.

Continue reading “Controlling Lots of Outputs from a Microcontroller”

Tilty ball: Controlling 64 LEDs and a 2-axis accelerometer

This example shows how to control 64 LEDs and read the input from two axes of an accelerometer on an Arduino.  The Arduino used here is a Duemilanove, but it will work on any of the models out there prior to the Duemilanove as well.  This example uses row-column scanning as a way to control more LEDs than you have output pins.  It also uses some of the analog pins as digital I/O pins.

Parts you’ll need

  • Arduino Duemilanove or equivalent
  • 2-axis accelerometer. I used the ADXL335 breakout board from adafruit.com, and only used two axes.
  • 8×8 LED matrix.  I used one I bought surplus.  See this post for details on figuring out your matrix’s pins if you don’t have the data sheet.
  • Breadboard or prototyping shield.  I used the proto shield and tiny breadboard from adafruit.com.

Continue reading “Tilty ball: Controlling 64 LEDs and a 2-axis accelerometer”