const int latchPin = 12; //Pin connected to ST_CP of 74HC595 const int clockPin = 8; //Pin connected to SH_CP of 74HC595 const int dataPin = 11; // Pin connected to DS of 74HC595 const int photocellPin = A0; // A attach to A0 int photocell = 0; unsigned char code_val[] = {0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; //Display different numbers of LEDs void setup() { //set pins to output pinMode(latchPin,OUTPUT); pinMode(clockPin,OUTPUT); pinMode(dataPin ,OUTPUT); } void loop() { photocell = analogRead(photocellPin); //read the value of A0 int digital=map(photocell,0,1023,0,8); //Value read is divided into 8 equal portions digitalWrite(latchPin,LOW); shiftOut(dataPin,clockPin,MSBFIRST,code_val[digital]); /* return the latch pin high to signal chip that it no longer needs to listen for information */ digitalWrite(latchPin,HIGH); //pull the latchPin to save the data delay(1); }