Help with led strip and ultrasonic sensor for garbage bin project

Hello, I’m doing a project where we are making a garbage bin that has to indicate how full it is by light. So I have hooked up a ultrasonic sensor with an NeoPixel Stick - 8 x 5050 RGB LED from adafruit. I want the light to go on one at a time depending how full the trashbin is. So when its completly full all of the lights will be on. And when its half full half the lights will be on. Something like this Arduino Ultrasonic Sensor with LED Strip - YouTube
I tried googling if anyone had made a code i could get inspiration from but it just ended up confusing me even more.
Im new to programming so i could use some help with what im doing wrong. At the moment i have tried making the first 3 leds light up according to the sensor. but they all light up at the same time and not one at a time depending on the distance from the sensor. Can anyone help med

#include <FastLED.h>

 #define LED_PIN     7
#define NUM_LEDS    8

 #define trigpin 6 
    #define echopin 5

  CRGB leds[NUM_LEDS];
   

    void setup()

     { 
      Serial.begin(9600);
       pinMode(trigpin,OUTPUT); //set trigpin as output
       pinMode(echopin,INPUT);//set echopin as input
 

      FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
    }

    void loop() 

    {
      int duration, distance;//declare distance and duration as integers
      
      digitalWrite(trigpin,HIGH);// trigin send out signal
      
      _delay_ms(1000);//coninously for 1000ms
      
      digitalWrite(trigpin, LOW);// then goes low

      duration=pulseIn(echopin,HIGH); // duration is the pulseIn to the echopin
      
      distance=(duration/2)/29.1; //  the 29.1 is used to convert the distnce to cm, the value varies for other units.
//Række 1
      if(distance > 0 && distance <= 5){
       leds[0] = CRGB(255, 0, 0);
        FastLED.show();
      _delay_ms(500);
      }
//Række 2      
      else if(distance > 5 && distance <= 10 ){
          leds[0] = CRGB(255, 0, 0);
          leds[1] = CRGB(0, 255, 0);
  FastLED.show();
   _delay_ms(500);
          }
//Række 3
           else if(distance > 10 && distance <= 15 ){
           leds[0] = CRGB(255, 0, 0);
           leds[1] = CRGB(0, 255, 0);
           leds[2] = CRGB(0, 0, 255);
            FastLED.show();
  _delay_ms(500);
          }
       Serial.print("cm");
      Serial.println(distance);//print values on serial monitor
      _delay_ms(100);
    }
      distance=(duration/2)/29.1; //  the 29.1 is used to convert the distnce to cm, the value varies for other units.

It would be useful to know just what distance contains.

Once a pixel is assigned a color, it is never assigned another color. So, once it is on, it will always be on, even if the distance changes.

An ultrasonic sensor is probably NOT the best choice. They work best with hard surfaces to reflect off of. The contents of the garbage bin probably include very few hard surfaces.