I am attempting to make an LED matrix such as in this tutorial: http://www.appelsiini.net/2011/how-does-led-matrix-work. Is there any way I can control components being grounded whilst keeping as many of the other GPIO pins free as possible? Any help that could be given would be greatly appreciated.

  • The 5V, 3.3V, and ground pins are hardwired. You cannot control them. However, if you explain in more detail exactly what you want to accomplish someone may have a suggestion -- e.g., GPIO pins set as outputs can be used to sink (a small amount of) current. – goldilocks Jan 23 '17 at 19:37
  • 1
    People have been using charlieplexing to use fewer gpios. en.m.wikipedia.org/wiki/Charlieplexing – PaulF8080 Jan 24 '17 at 10:28

Reading the Wikipedia link given by @PaulF8080 suggests that it would not be possible to do use the Charlieplexing technique to drive an LED matrix from the GPIO pins as in any multiplexing situation you trade a constant current on a continuous basis for a higher pulsed current on an intermittent (but regular repetitive basis) - the RPi GPIO outputs just can't do this directly for a large number of outputs.

One alternative approach to driving a large number of LEDs is the one which uses only one or a couple of lines to supply serial data to specify how bright each LED (or how bright each colour LED for RGB or WRGB) device should be. For the most economic devices you have the WS8211b devices which only uses a single GPIO line BUT that must be a PWM output pin and has a quite tightly specified serial protocol and precludes the use of the audio output - however there is code for this on the RPI_WS281x GitHub repository.

However it is much, much easier if you use an array of LED devices that uses a separate clock line as well as a data line to implement a serial bus to control them so you are looking for ones that use the APA102 protocol such as these from Adafruit which can be done on the SPI bus - see the "Which addressable RGB LED strips are beginner friendly and Raspberry Pi friendly" question for some more information.

| improve this answer | |
  • Charlieplexing is a clever way of using fewer control signals IMHO. How you drive the signals is another issue. No LEDs with added logic are needed. – PaulF8080 Jan 25 '17 at 1:16
  • If anything goes wrong with the timings of the sequence and the voltage pulses are large enough to produce a current powerful enough to drive a specific LED to sufficient brightness over the interval when that LED is SUPPOSED to be on to nearly compare with a continuous current then it is quite possibly powerful enough to nuke that diode and then - in similar manner to a series chain of "fairy-lights" each with a anti-fuse to by-pass it on filament failure - it will expose other LEDs to abnormal stresses that will aide in cascade failures... – SlySven Jan 25 '17 at 19:49
  • ...An RPi software driven sequencing of the GPIO pins will be subject to irregularities due to interrupts and other features of the RPI being a CISC - at least IMHO; remember the RPi is NOT a simple micro-controller. – SlySven Jan 25 '17 at 19:51
  • He needed more gpios and asked if ground pins could used. I answered another way to gets pins. Why you made the assumption we need to know every thing you know about LEDs is a mystery to me. The first LED matrix I worked on was 40+ years ago. – PaulF8080 Jan 25 '17 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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