Pages: [1]   Go Down
Author Topic: shift registers and row of leds  (Read 429 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 87
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi... I chained 2 shift registers with a bank of leds to attached each and successfully had them light up one at a time. Great.

Now I want to scale up.

I added another shift register and 8 more leds...

I have not been able to modify the following program (which I got off the internet and modified) to correctly light up the leds from 0 to 24 or 32 or 40... I want to understand how to modify the program so that I can chain any number of shift registers and be able to light up the full string or any individual led...

I would very much appreciate the help!!!!

Here it is:

// chain multiple shift registers, each with 8 leds
// light 1 led at a time, from 1 to 24 - blanking out each previous lit led
// then start again
//
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;

void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
digitalWrite(latchPin, 0); //make sure data isn't latched
}
void loop() {
unsigned int outputpattern =1; //stores the output pattern as an unsigned int, that is, two bytes
int pattern_LSB; //the least significant byte (LSB) of the pattern
int pattern_MSB; //the most significant byte (MSB) of the pattern
for (int i=0 ; i< 16; i++){
pattern_MSB = outputpattern >>8; //extract the MSB of the pattern by shifting all the bits over by 8
pattern_LSB = outputpattern & B11111111; //extract the LSB of the pattern by bitwise AND
shiftOut(dataPin, clockPin, MSBFIRST, (byte) pattern_MSB);
shiftOut(dataPin, clockPin, MSBFIRST, (byte) pattern_LSB);
digitalWrite(latchPin, 1); // flick the latch to put the data on the output pins
delay(1);

digitalWrite(latchPin, 0);
delay(100);

outputpattern = outputpattern <<1; // shift the outputpattern left by one bit

}
}

Logged

Cumming, GA
Offline Offline
Edison Member
*
Karma: 20
Posts: 1655
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

{edit}

Nevermind...

You got your question asked and answered in a different forum...
« Last Edit: October 23, 2009, 05:12:19 am by pwillard » Logged

Pages: [1]   Go Up
Jump to: