Go Down

Topic: Multiplexing RGB LEDs (Read 1 time) previous topic - next topic

CrossRoads

Method to Multiplex 10 RGB LEDs with 5 PNP transistors and a 74HC595.
Limit current into 74HC595 to 70mA MAX.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

robtillaart

Thanks,
do you have some code too?
does this work with PWM too?

(yes I know one mad men can ask more than 10 wise can answer;)

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

CrossRoads

#2
Feb 02, 2013, 08:36 pm Last Edit: Feb 02, 2013, 08:43 pm by CrossRoads Reason: 1
Sure, put PWM on the OE pin instead of grounding it.

Code: [Select]
#include <SPI.h>
byte pinArray[] = {2,3,4,5,6,}; // Arduino pins
byte dataArray[5]; // data to turn RGBs on/off, 1 byte per row, bit 6-7 not used in this example
byte rowEnable;
byte ssPin = 10;
byte x;

unsigned long currentmillis;
unsigned long priormillis;
unsigned long duration = 5; // 5 mS udpates, 25mS total refresh time (40 Hz)

void setup(){
// setup output pins, HIGH to turn off PNPs
for (x=0; x<5; x=x+1){
pinMode (pinArray[x], OUTPUT);
digitalWrite (pinArray[x], HIGH);
}
pinMode (ssPin, OUTPUT);
digitalWrite (ssPin,  HIGH);
SPI.begin();
}
void loop(){
// My method to multiplex a display
// Loop thru the row, but update when a time has elapsed
// Is a for-next loop, but with time check mixed in, so traditional for-next format is broken up
// see if time to change the display
currentmillis = millis();
if ( (currentmillis - priormillis)>=duration){
// set up for next time check
priormillis = priormillis + duration;
// turn off prior row
digitalWrite(pinArray[rowEnable], HIGH);
// set up for the next row - this is where the for-next is broken up
rowEnable = rowEnable +1;
// reset when reach the end
if (rowEnable ==5){
rowEnable = 0;}
// write cathode data
digitalWrite(ssPin, LOW);
SPI.transfer(dataArray[rowEnable]);
digitalWrite(ssPin, HIGH);
// Enable Anode
digitalWrite(pinArray[rowEnable], LOW);
} // end dataArray writing

// code to perform dataArray goes here

} // end void loop

Compiled & passes. Up to user to develop code towards the end to define what is displayed.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Hippynerd

It looks nice, but the specific parts (like a bill of materials) would make it easier. It looks like things are limited to 60mA, would about any npn transitor would work?

LED specifications will vary, so its hard to build the BOM when you dont know the LEDs forward voltage or current specifications.

It looks to me that you are planning on running the LEDs at about 10ma, to keep the shift register down to 60mA. That does require that only one transistor is turned on, and should something cause more than one transistor being on(program crash,...), could cause a situation where more than 70mA could happen.

This would also be a handy circuit for controlling 30 LEDs.

P.S. Im still working on a 64 RGB LED cube with 20 NPN transistors Im using tiny 2n2222s to sink upto 240mA.

This might be a curious way to make a 10x10x10 RGB LED cube or 10x10 matrix.

CrossRoads

LED size - 3mm, 5mm, 10mm, SMD, thruhole, infinite choices of brightness. Same for Vf. 
Transistor must be PNP, not NPN.
Shift register can be 74HC595, or TPIC6B595 for more current sinking capacity.
Resistors sized to suit the other components.

That's why no BOM is provided.
Expand it higher or wider as needed.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Go Up