Hey Arduino Forum,
I'm fairly new to Arduino and electronics in general, I'm currently working on a project involving a 4x4 LED matrix. I didn't put this post in the LED section because there's nothing wrong with the LED part of it.
Skip to the next paragraph if you just want to get to the problem.
I wired up the LEDs in such a way that each column of cathodes is connected to one pin (4 pins), and each row of anodes is wired to a single pin (4 pins); for a total of 8 pins used, rather than 16. My plan was to connect each pin to ground or +5v so that I could control exactly which LED's were on. For example, to light up an LED on the 3rd row, 1st column, you would put the 3rd row to +5v, and the first column to ground, turning on only one LED. There's probably a name for this; I don't know what it's called though.
My issue is, that there's no way that I know of to set one of the pins to "nothing", they all default to ground, or LOW.
This is an issue because now I can only choose which complete row of LEDs is illuminated, as all columns are auto-set to ground.
Would hooking up some transistors to the ground columns work?
Would using my +5v as an "off" state for the cathodes work, as the LEDs are diodes?
I don't really want to ruin an entire row of LEDs, or screw something up on my arduino.
Any help is appreciated, thanks for your time.
I can post the code that I have if you want.
For slightly technical reasons you should actually do this to make a pin
open-circuit:
digitalWrite (pin, LOW) ; pinMode (pin, INPUT) ;
By open-circuit I actually mean "high impedance state so long as
pin voltage is between 0V and 5V".
You have invented multiplexing, but you don't mention current-limiting
resistors - you need to add them to one set of pins.
In fact there's a more densely packed multiplexing scheme called
Charlieplexing that can do 20 LEDs with 5 pins and 5 resistors.
Its limited to LEDs of similar forward voltage though, you can't
mix red and blue for instance.
So basically, setting the pinMode to "input" will make it open-circuit? That makes sense.
I already have current-limiting resistors on each LED; I suppose you're right, I could have just put one on each row.
Yeah, I've heard of charlieplexing, it seemed unnecessarily dense; I don't really mind using a lot of pins as long as they are few enough to fit on my arduino. I'll look into it a bit more, though.
Thanks for the help; I'll go try it.
petersboro:
So basically, setting the pinMode to "input" will make it open-circuit?
As advised above, you should set the output state to LOW first. The I/O pins have internal pull-up resistors that are enabled automatically when the pin is configured as an input and set to a HIGH state.
For slightly technical reasons you should actually do this to make a pin
open-circuit:
digitalWrite (pin, LOW) ; pinMode (pin, INPUT) ;
By open-circuit I actually mean "high impedance state so long as
pin voltage is between 0V and 5V".
You have invented multiplexing, but you don't mention current-limiting
resistors - you need to add them to one set of pins.
In fact there's a more densely packed multiplexing scheme called
Charlieplexing that can do 20 LEDs with 5 pins and 5 resistors.
Its limited to LEDs of similar forward voltage though, you can't
mix red and blue for instance.
Mark;
Does not the current form of pinMode(pin#, INPUT); also turn off the internal pull-up as well as set mode to input?
I believe that behavior occurred when they added the pinMode(pin#, INPUT_PULLUP); option at some IDE 1.0.x version.
I ask that because of the time of this 'improvement' some did state or ask if it could 'break' someone's older code that
might have counted on input pull-up being active upon switching a pin from output to input mode if the last output state was HIGH.