Author Options:

Multiplexing query? Answered

Hi, I am having a problem with multiplexing. I have my grid set up with 60 leds all connected in rows and columns as per usual and my eventual goal is to have each led come on one after another. Sorry I can't think of a single term to describe this action at the moment. This is for a clock, in particular the seconds but the way I see it, when row 1 (my cathodes) is high ie to ground and after each column (my anodes) is lit sequentially (found my single term) when I get to the next row of LED's, it seems that as columns 1-8 are already high, when row 2 goes high then all the LED's in that row will light simultaneously.
 If I could have some pointers, that would be great.
Many thanks

Additional information: My set of LED's will be run off a PIC 28X2 with DS1307 RTC in case anyone needs to know.


The forums are retiring in 2021 and are now closed for new topics and comments.

8 years ago

Show us your circuit. There's a way to make it work. But without knowing what you are trying I'm blind.

LED Maestro
LED Maestro

Answer 8 years ago

Thank you guys for your your help. Re-design, I don't have a circuit as yet. I have only just started on my project. I will try and put one together ASAP for you. Frollard, thank you for your help. I thought of lighting each row individually but wasn't sure about it but I think it might be the way to go. And thanks for the code also. It's a great help.
Once again many thanks


8 years ago

The trick is you can only turn on one row at a time, flashing the bits of that row that need lighting by connecting those columns. After the first row, you turn off the first row, then turn on the second row and display the bits you want in the 2nd row, repeat.

You can never display all the bits at the same time, but if you flash through them quickly enough the eye will think they are all turned on as appropriate.

all row outputs 0
for rowNum = 0, row < 8, row++
row[rowNum] = on; //turn on only the one row
columnOutput[0-7] = whatever that 8 bits should be for this row number
delay a few ms to make it brighter
columnOutput[0-7] all off //turn the column data back off
row[rowNum] = off; // turn off the current row to get ready for the next
end for

end loop


Answer 8 years ago

*to clarify; you need 8 pins driving the rows and 8 pins driving the columns, one sourcing and one sinking current.

If you don't have enough pins you can use shift registers.

if you only ever want 1 led on at a time:

//asynchronous, just updates the seconds about once per second, not truly accurate.

for (row = 0, row < 8, row++){
rowOutput[row] = 1;
for (col = 0, col < 8, col++){
colOutput[col] = 1;
delay(1 second);
colOutput[col] = 0;
} //end col for
rowOutput[row] = 0;
}// end row for

or if you want a function to feed the second number, and it does the work;

//takes a number 0-63 and decides which row/column to light
void numToRowCol(byte Seconds){
byte row = (Seconds % 8); //modulus to find how many spare seconds
//returns 0-7 for input 0-63
byte col = (Seconds - row) / 8; //decide which column should be on, subtract row to get the multiple of 8, then divide to get the column number
//returns 0-7 for input 0-63
allOutputsOff(); //turn off all the outputs, you can figure it out
setOutput(row,col); //turn on the appropriate row and column, you can figure that part out.

}//end void numToRowCol