Go Down

Topic: 24 bits with an 74HC595 (Read 599 times) previous topic - next topic

thomgrr

Hi,

I'm working on a project to control 24 leds with 3 74HC595 IC's. I've chained the 3 74HC595's together to create an 24bit shiftregester.
I would like to use the "shiftOut" function on the arduino with arduino pin 4 to 595 pin 11, arduino pin 3 to 595 pin 12 and arduino pin A5 to 595 pin 14.
this is what I would like to use to control the leds:

    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, ...);   
    digitalWrite(latchPin, HIGH);

The only this is that I don't know what to use on the ... ?
If I would like to light al leds at once or light some, can I use binary notation like 111111111111111111111111?

Your advice a reaction would be greatly appreciated


Kind regards,
Thom

PaulRB

#1
Apr 12, 2017, 08:03 pm Last Edit: Apr 12, 2017, 08:04 pm by PaulRB
Code: [Select]
    unsigned long pattern = 0b111111111111111111111111;
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, pattern);   
    shiftOut(dataPin, clockPin, LSBFIRST, pattern>>8);   
    shiftOut(dataPin, clockPin, LSBFIRST, pattern>>16);   
    digitalWrite(latchPin, HIGH);

thomgrr

Thanks a lot!!!
This code is working niceley and this makes it a lot easier!

Go Up