2 //**************************************************************//
3 // Name : shiftOutCode, Hello World
4 // Author : Carlyn Maw,Tom Igoe, David A. Mellis
6 // Modified: 23 Mar 2010
8 // Notes : Code for using a 74HC595 Shift Register //
9 // : to count from 0 to 255
10 //****************************************************************
12 //Pin connected to ST_CP of 74HC595
14 //Pin connected to SH_CP of 74HC595
16 ////Pin connected to DS of 74HC595
22 //set pins to output so you can control the shift register
23 pinMode(latchPin, OUTPUT);
24 pinMode(clockPin, OUTPUT);
25 pinMode(dataPin, OUTPUT);
28 Serial.print("Decimal");
30 Serial.println("Binary");
34 // count from 0 to 255 and display the number
36 for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) {
37 // take the latchPin low so
38 // the LEDs don't change while you're sending in bits:
39 digitalWrite(latchPin, LOW);
41 // shift out the bits:
42 shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);
44 //take the latch pin high so the LEDs will light up:
45 digitalWrite(latchPin, HIGH);
47 Serial.print(numberToDisplay);
49 Serial.println(numberToDisplay, BIN);
50 // pause before next value: