1 //**************************************************************//
2 // Name : shiftOutCode, Hello World
3 // Author : Carlyn Maw,Tom Igoe, David A. Mellis
5 // Modified: 23 Mar 2010
7 // Notes : Code for using a 74HC595 Shift Register
9 // : to count from 0 to 255
10 //****************************************************************
13 //Pin connected to ST_CP of 74HC595
15 //Pin connected to SH_CP of 74HC595
17 ////Pin connected to DS of 74HC595
20 //set pins to output so you can control the shift register
21 pinMode(latchPin, OUTPUT);
23 pinMode(clockPin, OUTPUT);
24 pinMode(dataPin, OUTPUT);
27 // count from 0 to 255 and display the number
29 for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) {
30 // take the latchPin low so
31 // the LEDs don’t change while you’re sending in bits:
32 digitalWrite(latchPin, LOW);
33 // shift out the bits:
34 shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);
35 //take the latch pin high so the LEDs will light up:
36 digitalWrite(latchPin, HIGH);
37 // pause before next value: