Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

What you are looking for in that case is a 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 a LED matrix to the I2C bus, using one or multiple I2C I/O extenders. That way you can create a matrix of a huge size (64 LEDs for example 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 keeping your main CPU out of harms way.

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

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

share|improve this answer
    
This is very interesting. Thanks for the read! I might try this in small scale using the GPIO pins before I am ready to move onto extenders. I have done some tests with the GPIO pins and so far I have been able to get satisfactory Multiplexing. I am not to worried about the current since I will only be using the Pi to switch an external current. Will this scale well? Probably not, but I'm here mostly for the lesson anyways! –  SkyNT Jan 31 '13 at 5:33

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.