 {
   leds = 0;
   updateShiftRegister();
-  delay(500);
-  for (int i = 0; i < 8; i++)
+  /* delay(500); */
+  for (int i = 0; i < map(analogRead(lightPin), 40, 115, 0, 7); i++)
   {
     bitSet(leds, i);
     updateShiftRegister();
-    delay(500);
   }
 }
 

int latchPin = 5;
int clockPin = 6;
int dataPin = 4;

byte leds = 0;


  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(lightPin, INPUT);
  Serial.begin(9600);
}

void updateShiftRegister()
