ping sensor to 6 led

i’m a starter in Arduino programs and I wanted to make the pingsensor convert distance to brightness for 6 led lights all at once
I’ve finished the code with the help of my teacher but the only led that works is pin 5
Is anyone experienced in understanding malfunctions within the code?
Thanks in advance

const int PingPin = 7;     //sets signal pin for the PING
int ledPins[] = {3,5,6,9,10,11};
int brightness = 0; 

void setup() 

 for(int i = 0; i <= 6; i++)
  Serial.begin(115200); //Sets up serial should you need it

void loop() 
   int i = 0; i <= 6; i++;
  digitalWrite(ledPins[i], LOW);

int cm = findDistance();  //calls down to the code block at the bottom of the sketch to run the Ping and find CM
if (cm >50 || cm ==0)
    digitalWrite(ledPins[i], LOW);
   int cm = findDistance();

   brightness = map(cm, 50, 0, 0,255); 

  Serial.println("cm, "); 

  Serial.print("brightness = ");
  analogWrite(ledPins[i], brightness);
  int cm = findDistance();
// When this block of code is called, it runs the PING sensor and returns CM
int findDistance() 

  long duration, inches, cm;
  pinMode(PingPin, OUTPUT);
  digitalWrite(PingPin, LOW);
  digitalWrite(PingPin, HIGH);
  delayMicroseconds(5);          // The same pin is used to read the signal from the PING))): a HIGH
  digitalWrite(PingPin, LOW);   // pulse whose duration is the time (in microseconds) from the sending
  pinMode(PingPin, INPUT);   // of the ping to the reception of its echo off of an object.
  duration = pulseIn(PingPin, HIGH); 

  cm = duration / 29 / 2; // convert the time into a distance
  return cm; // sends CM back to the block that called it

What is the value of i when you use it in the if/else statement?

Also, why are you reading the sensor after you have processed the first read of the sensor. The value is not stored or used, so it is a wasted effort.

 int i = 0; i <= 6; i++;

Declare a variable i, and assign it the value 0.
Test to see if i is less than or equal to six, and discard the result.
Increment i.

Did you forget a “for”, perhaps? (if you did, that should be “i < 6”)