// LED driver
// Pin connected to ST_CP of 74HC595
int latchPin = 30;
// Pin connected to SH_CP of 74HC595
int clockPin = 31;
// Pin connected to DS of 74HC595
int dataPin = 32;
// Pin connected to OE of 74HC595
int oePin = 29;
// Setup -------------------------------------------------------
void setup()
{
// init LED driver 74HC595
// During initialization, the OE pin on the 74HC595 has
// high level via a transistor inverter
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(oePin, OUTPUT);
digitalWrite(oePin, LOW);
// set LED Status ----------------------------------------------
void set_LED_Status()
{
if (update_LED_Status_Timer >= 170)
{
update_LED_Status_Timer = 0;
static uint32_t data = 1;
for (int numberToDisplay = 0; numberToDisplay < 3; numberToDisplay++) {
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out highbyte
shiftOut(dataPin, clockPin, MSBFIRST, (data >> 16));
// shift out middelbyte
shiftOut(dataPin, clockPin, MSBFIRST, (data >> 8));
// shift out lowbyte
shiftOut(dataPin, clockPin, MSBFIRST, data);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
}
// shift one bit right and turn on one of 24 LEDs
digitalWrite(oePin, HIGH);
data = data << 1;
if (data == 0)
{
data = 1;
}
}
}