Code to control 8 LEDs with on Photocell

Hi everyone!
Essentially I’m trying to do this thing where the breadboard is in a box and when you open the box the LEDs light up but when you close the box the LEDs turn off. How I went about doing that was using 8 LEDs and 1 photocell to the Arduino. My only issue is with the coding. In the "void loop () " section I tried writing: digitalWrite (ledPin1, OUTPUT) for every single LED. That didn’t end up working because they weren’t lighting up together so I was wondering if there was another way to go about coding it.

Any suggestions would be highly appreciated :))

Without the whole code it is impossible to help you. Please post your code.

const int buttonPin1 = 2;
const int buttonPin2 = 3;
const int buttonPin3 = 4;
const int buttonPin4 = 5;
const int buttonPin5 = 6;
const int buttonPin6 = 7;
const int buttonPin7 = 8;
const int buttonPin8 = 9;

const int sensorPin = A0;
int sensorValue = 0;

void setup() {
// put your setup code here, to run once:
pinMode (buttonPin1, OUTPUT);
pinMode (buttonPin2, OUTPUT);
pinMode (buttonPin3, OUTPUT);
pinMode (buttonPin4, OUTPUT);
pinMode (buttonPin5, OUTPUT);
pinMode (buttonPin6, OUTPUT);
pinMode (buttonPin7, OUTPUT);
pinMode (buttonPin8, OUTPUT);

Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);

digitalWrite(buttonPin1, HIGH);
digitalWrite(buttonPin2, HIGH);
digitalWrite(buttonPin3, HIGH);
digitalWrite(buttonPin4, HIGH);
digitalWrite(buttonPin5, HIGH);
digitalWrite(buttonPin6, HIGH);
digitalWrite(buttonPin7, HIGH);
digitalWrite(buttonPin8, HIGH);

delay(sensorValue);

digitalWrite(buttonPin1, LOW);
digitalWrite(buttonPin2, LOW);
digitalWrite(buttonPin3, LOW);
digitalWrite(buttonPin4, LOW);
digitalWrite(buttonPin5, LOW);
digitalWrite(buttonPin6, LOW);
digitalWrite(buttonPin7, LOW);
digitalWrite(buttonPin8, LOW);

delay(sensorValue);
}

digitalWrite (ledPin1, OUTPUT)

That makes no sense. Look at the reference for digitalWrite(). You can write a pin LOW or HIGH. The pinMode() can be OUTPUT, INPUT or INPUT_PULLUP. The pinMode is usually set in setup() as it will not change during execution of the program (though there are exceptions).

What kind of photocell and how is it wired to the arduino, Vcc and Gnd?
The Arduino is limited in sourcing current to the output pins. 8 leds is too much current if driven at max power.
Somesort of schematic how things are wired would be helpfull as well.
What excactly do you mean by “That didn’t end up working” ?