Potentiometer Controlled LEDs

What I am trying to accomplish here is a row of Leds that light up when the pot is turned. I have the pot connected to pin A0 and the positive of the LED hooked up to pin 2. Here is my code

int sensorValue = analogRead(A0);

void setup() {

  Serial.begin(9600);
}


void loop() {
  Serial.println(sensorValue);
  delay(10);
  led();
}


void led() {
    
    if(sensorValue > 0)
    {
      pinMode(2, OUTPUT);
    }
  }

When I compile the code no errors are found but the serial monitor only shows 0 as I turn the pot. Any help is welcome.

You need to read the analog value inside your led function, otherwise its only read once when the code initially starts

Ok thanks that solved my serial monitor readings by putting sensorValue = analogRead(A0); into the loop function but now the if statements are not doing anything my code is:

int sensorValue = analogRead(A0);

void setup() {

  Serial.begin(9600);
}


void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  delay(10);
  led();
}


void led() {
    
    if(sensorValue > 0)
    {
      pinMode(2, OUTPUT);
    }
  }

I have tried changing the pin mode to high and low but the if statement is not working at all

int sensorValue = analogRead(A0);

void setup() {

  Serial.begin(9600);
}


void loop() {
  sensorValue = analogRead(A0);  // You have to remove the int
  Serial.println(sensorValue);
  delay(10);
  led();
}


void led() {
    
    if(sensorValue > 0)
    {
      pinMode(2, OUTPUT);
    }
  }

@BillHo Using your code nothing changes my led still does not light up

int sensorValue = analogRead(A0);

void setup() {

  Serial.begin(9600);
  pinMode(2, OUTPUT);
}


void loop() {
  sensorValue = analogRead(A0);  // You have to remove the int
  Serial.println(sensorValue);
  delay(10);
  led();
}


void led() {
    
    if(sensorValue > 0)
    {
      digitalWrite(2, HIGH)
    }  
  }

Thank you BillHo your code has fixed my problem