12

I successfully completed my hardware "hello world" using this guide:

http://www.raspberrypi-spy.co.uk/2012/06/control-led-using-gpio-output-pin/

Now I'd like to move on to bigger and brighter things, more individually controlled LEDs that is! Obviously, the next step is to move the voltage source off of the Raspberry Pi and to add more LEDs, but eventually I am going to run out of GPIO pins, so I guess what I need now is to control a circuit which will somehow know, based on GPIO "coded signals", what LEDs to turn on and off. What sort of circuit examples should I be looking for? And more importantly vis-a-vis the Raspberry Pi, could it or rpi.gpio cause any problems, perhaps regarding signal timing?

SkyNT
  • 223
  • 1
  • 2
  • 6

2 Answers2

13

What you're looking for in that case is an LED matrix. You could control this matrix from the GPIO pins, but that still limits the amount of LEDs you can connect (the size of the matrix) and it might also start to draw too much current if you're not careful.

A better option is to connect an LED matrix to the I2C bus, using one or multiple I2C I/O extenders. That way you can create a matrix of a larger size (for example, 64 LEDs can be done with ONE 16 bit I/O extender). Another reason to use these I/O extenders is that they are a little more robust, can provide a little more current, and keep your main CPU out of harm's way.

These I/O extenders are discussed multiple times on this site, so you should be able to find info about them quite easily. This Link provides some info about them and a matrix (although used for input, but basically it's the same idea but you don't use the matrix to scan but to steer the LEDs).

The only extra requirement for making a smooth, working matrix is that you need to make the matrix not bigger than the RPi is able to update each individual LED at least 20 times per second, otherwise you'll start to see flickering, but this is also explained in the first link (paragraph "Multiplexing and Persistence of Vision").

ikku
  • 4,544
  • 1
  • 26
  • 28
3

I've used the MCP23017 I²C port expander to do this type of thing. Follow this link to find some sample code for the raspberry pi. You can drive 16 LEDS per chip and 8 chips without needing to do any multiplexing.

John La Rooy
  • 12,005
  • 9
  • 48
  • 77