Help with shift register and photo resistor.

I am making a binary clock and works perfectly except I want the LEDs to get dimmer when the lights around it do. I’ve looked everywhere but I can’t find out how to use the photo resistor with the shift register. Thanks!

int secPins[] = {1 ,2, 3, 4, 5, 6};
int minPins[] = {10, 9, 8, 7, 6}; 
int shiftMinPin = 7;
int hourPins[] = {5, 4, 3, 2};
int hours = 5;
int mins = 25;
int secs = 0;
int datapin = 11; 
int clockpin = 12;
int latchpin = 13;
int data = 0;
int sensorPin = 0;
int lightLevel, high = 0, low = 1023;
void setup()
{
  Serial.begin(9600);
  pinMode(datapin, INPUT);
  pinMode(datapin, OUTPUT);
  pinMode(clockpin, OUTPUT);  
  pinMode(latchpin, OUTPUT);
  for(int x = 0; x < 6; x++)
  {
    pinMode(secPins[x], OUTPUT);
  }
  pinMode(shiftMinPin, OUTPUT);
  
  for(int x = 0; x < 5; x++)
  {
    pinMode(minPins[x], OUTPUT);
  }
  
  for(int x = 0; x < 4; x++)
  {
    pinMode(hourPins[x], OUTPUT);
  }
  
}

void shiftWrite(int desiredPin, boolean desiredState) {
  bitWrite(data,desiredPin,desiredState);
  shiftOut(datapin, clockpin, MSBFIRST, data);
  digitalWrite(latchpin, HIGH);
  digitalWrite(latchpin, LOW);
}

void loop() {
  lightLevel = analogRead(sensorPin);
  autoTune();
  for(int x=0; x<6; x++) {
    analogWrite(secPins[x], lightLevel);
  }
  analogWrite(shiftMinPin, lightLevel);
  for(int x=0; x<5; x++) {
    analogWrite(minPins[x], lightLevel);
  }
  for(int x=0; x<4; x++) {
    analogWrite(hourPins[x], lightLevel);
  }
  */
  setTime(hours, mins, secs);
  secs++;
  if(secs > 59) {
    mins++;
    secs = 0;
  }
  if(mins > 59) {
    hours++;
    mins = 0;
  }
  if(hours > 12) {
    hours = 1;
  }
  delay(1000);
  
}

void setTime(int hour, int mins, int sec)
{
  
  String strSec = printBinary(sec, 6); //String(sec, BIN);
  String newStr = "";
  for(int x = 5; x >= 0; x--) {
    newStr = newStr + strSec.charAt(x);
  }
  for(int x = 0; x < strSec.length(); x++) {
    if(newStr.charAt(x) == '0')
    {
      shiftWrite(secPins[x], LOW);
    }
    if(newStr.charAt(x) == '1')
    {
      shiftWrite(secPins[x], HIGH);
    }
  }
  
  
  String strMins = printBinary(mins, 6);
  String newStrMins = "";
  for(int x = 5; x >= 0; x--) {
    newStrMins = newStrMins + strMins.charAt(x);
  }
  Serial.println(newStrMins);
  if(newStrMins.charAt(0) == '0') {
    shiftWrite(shiftMinPin, LOW);
  }
  if(newStrMins.charAt(0) == '1') {
    shiftWrite(shiftMinPin, HIGH);
  }
  for(int x = 0; x < 5; x++) {
    if(newStrMins.charAt(x+1) == '0') {
      digitalWrite(minPins[x], LOW);
    }
    if(newStrMins.charAt(x+1) == '1') {
      digitalWrite(minPins[x], HIGH);
    }
  }
  
  
  String strHour = printBinary(hour, 4); 
  String newStrHour = "";
  for(int x = 3; x >= 0; x--) {
    newStrHour = newStrHour + strHour.charAt(x);
  }
  Serial.println(newStrHour);
  for(int x = 0; x < 4; x++) {
    if(newStrHour.charAt(x) == '0') {
      digitalWrite(hourPins[x], LOW);
    }
    if(newStrHour.charAt(x) == '1') {
      digitalWrite(hourPins[x], HIGH);
    }
  }
  
}

String printBinary(int v, int num_places)
{
    String binNum;
    int mask=0, n;

    for (n=1; n<=num_places; n++)
    {
        mask = (mask << 1) | 0x0001;
    }
    v = v & mask;  // truncate v to specified number of places

    while(num_places)
    {

        if (v & (0x0001 << num_places-1))
        {
             binNum = binNum + "1";
        }
        else
        {
             binNum = binNum + "0";
        }

        --num_places;
        if(((num_places%4) == 0) && (num_places != 0))
        {
            Serial.print("");
        }
    }
    return binNum;
}

void autoTune()
{
  if (lightLevel < low)
  {
    low = lightLevel;
  }
  if (lightLevel > high)
  {
    high = lightLevel;
  }
  lightLevel = map(lightLevel, low+30, high-30, 0, 255);
  lightLevel = constrain(lightLevel, 0, 255);
}

First of all, the analogRead function returns a value in the range from 0 to 1023, while the analogWrite function takes arguments from 0 to 255. So you need to adjust your values downward by a factor of four. Also realize that the values used in analogWrite() may not affect LED brightness in anything like a "linear" fashion, relative to your sight. You'll probably need to play with the input versus output value, say through a lookup table, to get an effect you want.

Also, not every pin on the Arduino will do the PWM associated with analogWrite().

I just recently used a photo resistor arranged in a voltage divider to dim aquarium lighting gradually as evening comes along. I had to play with the input/output values to get a lighting effect I was happy with.

Also, bear in mind that LED's do draw a fair amount of current. You may want to check your regulated voltage levels as you drive your clock digits to full brightness. I'm using 24 neopixels, and my voltage levels descend from 5.1 to 4.65 volts.

How are the LEDs and shift register wired. It would be helpful to see a schematic. I see “analogWrite” statements. Are these statements controlling LEDs directly?

PWM to the shift register OE/ pin is an easy way to control brightness.