SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By metalmagic
I new need some help with a shift register and an arduino. I am using the arduino and shift register to run some rgb leds. These leds have a common anode so I think I need to change the state of the shift registers to LOW. These are 74hc595n and I have the output enable pin grounded currently. Do I need to connect the output enable to a pin on the arduino and digitalWrite it high to change the state of the outputs to LOW all the time?
By killersquirel11
Guess what? It's Debugging time 8)

Step 1: Verify the correct voltages on all pins. So grab your multimeter, put the black probe to ground somewhere, then check the wires leading up to these pins for:
According to some quick googling:
8: GND - 0V
10: !MR - Master Reset - should be pulled HIGH (3.3V or 5V or whatever your circuit is running at). For testing, I'd recommend a several-kiloohm resistor from this pin to VCC and a normally-open switch between this pin and GND
11: Shift Register Clock Input - Make sure this is connected to a clock source. A multimeter with a frequency setting, or an oscilloscope could show that this is working correctly
12: Storage Register Clock Input - Could possibly be the same source as 11, not entirely sure on the operation of this part
13: !OE - Output Enable - Active Low, so should be connected to GND
14: Serial Data Input - Connected to the Arduino
16: VCC - set to the input voltage, whatever that is.
9: Serial Data output - should change several cycles after input
1-7, 15: Parallel Data Output

Once all that is verified, you can use the multimeter to probe the serial input, serial output, and parallel data output to see if those are changing the way they should be..
By stevech
suggestion.. connect the shift register's output enable to a microprocessor I/O bit. Disable the outputs while shifting. This will avoid big current spikes.
By macegr
stevech wrote:suggestion.. connect the shift register's output enable to a microprocessor I/O bit. Disable the outputs while shifting. This will avoid big current spikes.
Not following you on this Seems like it would actually create a huge current spike by turning off and then on every active LED, compared to possibly switching just one LED.
By macegr
stevech wrote:the output bits can toggle at the shift-clock rates while shifting bits down their positions.
You probably don't realize that the 74HC595 has a shift register AND a storage register. The output bits aren't going to change during shifting. They'll all change when the storage register clock is pulsed.
By icapdeville
Check this arduino reference

the anode to the 5V output and the cathode to data pins in the shift register (pins 15, 1-7)

to turn on all LEDs with common anode you send shiftOut(dataPin, clockPin, MSBFIRST, B00000000);
to turn off shiftOut(dataPin, clockPin, MSBFIRST, B11111111);

if you want sequences then use some arrays, i have 3 arrays (1 for each color) and 3 shift registers chained

a simple code to test random colors

int latchPin = 8; // shift register pin 12
int clockPin = 12; // shift register pin 11
int dataPin = 11; // shift register pin 14
int Power = 3; // to common anode in RGB LEDs to control brightness

void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(Power, OUTPUT);


void loop() {

int brightness = random (256) ;
int red = random (256);
int green = random (256);
int blue = random (256);

for (int i = 0; i < 20; i++){

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, blue);
shiftOut(dataPin, clockPin, MSBFIRST, green);
shiftOut(dataPin, clockPin, MSBFIRST, red);
digitalWrite(latchPin, HIGH);
analogWrite(Power, brightness);
delay(180); // milliseconds


and a image, with this arrange i can control individually each LED and each color