LED RGB Strip with Ultrasonic SRF05 sensor (HELP)

Hi, I’m very new to arduino and this is my first project so please don’t laugh at what I’m sure is a very easy solution haha!

I’m currently doing a project which involves a RGB LED strip and an ultrasonic SRF05 sensor.

I have got the LED strip working on its own and i have got the Sensor working on its own

my trouble now is to connect the code together so that the sensor uses the measuemrnts to dim/brighten the lights

my aim is someone walking up to the sensor will brighten up the lights and vice versa walking away dims the lights.

Can anyone help at all?!

I have attached the code i have for the sensor and the code for the LED’s

RGBSensorCode.zip (1.03 KB)

Please put your code into your post inside code tags, so we don't have to download and unzip your code to help you.

sorry I'm unsure of how to do that

click the code button (scroll with <> symbol), copy+paste code between the code tags.

Sensor Code

#define ECHOPIN 2                            // Pin to receive echo pulse
#define TRIGPIN 3                            // Pin to send trigger pulse

void setup(){
  Serial.begin(9600);
  pinMode(ECHOPIN, INPUT);
  pinMode(TRIGPIN, OUTPUT);
}

void loop(){
  digitalWrite(TRIGPIN, LOW);                   // Set the trigger pin to low for 2uS
  delayMicroseconds(2);
  digitalWrite(TRIGPIN, HIGH);                  // Send a 10uS high to trigger ranging
  delayMicroseconds(10);
  digitalWrite(TRIGPIN, LOW);                   // Send pin low again
  int distance = pulseIn(ECHOPIN, HIGH);        // Read in times pulse
  distance= distance/58;                        // Calculate distance from time of pulse
  Serial.println(distance);                     
  delay(50);                                    // Wait 50mS before next ranging
}

RGB LED CODE

int r, g, b;
 
  // fade from blue to violet
  for (r = 0; r < 256; r++) { 
    analogWrite(REDPIN, r);
    delay(FADESPEED);
  } 
  // fade from violet to red
  for (b = 255; b > 0; b--) { 
    analogWrite(BLUEPIN, b);
    delay(FADESPEED);
  } 
  // fade from red to yellow
  for (g = 0; g < 256; g++) { 
    analogWrite(GREENPIN, g);
    delay(FADESPEED);
  } 
  // fade from yellow to green
  for (r = 255; r > 0; r--) { 
    analogWrite(REDPIN, r);
    delay(FADESPEED);
  } 
  // fade from green to teal
  for (b = 0; b < 256; b++) { 
    analogWrite(BLUEPIN, b);
    delay(FADESPEED);
  } 
  // fade from teal to blue
  for (g = 255; g > 0; g--) { 
    analogWrite(GREENPIN, g);
    delay(FADESPEED);
  }