Arduino Program to Control 4 Bi-color LEDs through a 74595 Chip (Part 3 of 4)

<<<< Read Previous Part (Part 2)

We had already seen the working of 74595 chip in one of my previous post. It’s better to read my previous post to get a clear idea about the working of 74595. After completing the circuit given in part 1, upload the following program to your arduino board. If uploading is successful, two colors will appear in all the bi-color LEDs, one after other, in one second delay.

//Pin connected to ST_CP of 74HC595
int latchPin = 11;
//Pin connected to SH_CP of 74HC595
int clockPin = 10;
////Pin connected to DS of 74HC595
int dataPin = 12;

void setup() 
{
    //set pins to output so you can control the shift register
    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);
    pinMode(dataPin, OUTPUT);
}

void loop() 
{
       // take the latchPin low so 
       // the LEDs don't change while you're sending in bits:
       digitalWrite(latchPin, LOW);
       // shift out the bits:
       shiftOut(dataPin, clockPin, MSBFIRST, 170);  
       //take the latch pin high so the LEDs will light up:
       digitalWrite(latchPin, HIGH);
       // pause before next value:
       
       delay(1000);
       
       // take the latchPin low so 
       // the LEDs don't change while you're sending in bits:
       digitalWrite(latchPin, LOW);
       // shift out the bits:
       shiftOut(dataPin, clockPin, MSBFIRST, 85);  
       //take the latch pin high so the LEDs will light up:
       digitalWrite(latchPin, HIGH);
       // pause before next value:

       delay(1000);
}

Continued in Next Part (Part 4) >>>>

(Visited 138 times, 1 visits today)
paulpp644
A deep electronic enthusiast who spent most of my time for electronic experiments. I am also interested in publishing my experiments in my blog for helping other electronics enthusiasts.