Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: stothebear on May 08, 2011, 03:33 pm

Title: Controlling multiple LEDs using shift register
Post by: stothebear on May 08, 2011, 03:33 pm
I am using Arduino in a school project this semester and i'd like to hock Arduino Uno up with 50-60 LEDs using 74HC595 Shift registers and i can't find out how to induvidially control the LEDs. If anyone knows this stuff better than me and would like to help with some code-strips it would be much appriciated.

-stothebear-
Title: Re: Controlling multiple LEDs using shift register
Post by: Grumpy_Mike on May 08, 2011, 11:43 pm
Quote
i can't find out how to induvidially control the LEDs.

You have a byte array, one entry for each shift register.
When you want to turn an LED on or off you do a bit set or bit clear on the bit that corresponds to the LED you want to change and then write the whole array out to the shift registers.
Most of the LEDs are getting the same controlling bit as last time and so will not change, only the LED that you did the bit set or clear on will change.
Title: Re: Controlling multiple LEDs using shift register
Post by: CrossRoads on May 09, 2011, 12:01 am
Do you have pins to spare?  Consider this approach:
Wire the serial data out & shift clock lines together (pins 11 & 14), and use seperate load_clock lines (pin 12) so you can load each shift register independently for faster writes (do 1 shiftout command when there's a change in a byte, vs 7 or 8).  Each register will have its input register loaded, but only 1 will have the data transferred to its output register.

If you have the shiftouts as part of your overall loop, you can check if the data changed for any particular byte & shift out only the ones that changed.