BoBot Course Maneuver Code, PLEASE HELP

My friend and I have been working on this project for a while now and we are having no success with our code. Below is the code that we have and we really don’t know why our distance sensor isn’t working. On our robot we have two drive motors, a distance sensor, and an LED, all wired correctly. Can someone please tell me why my distance sensor isn’t registering?

I keep getting this error message: ‘dist_sensor_V’ was not declared in this scope


#include <Servo.h>
unsigned long start_time, elapsed_time;
Servo LeftWheel_servo;
Servo RightWheel_servo;
int analogPin=7;
int val= dist_sensor_V;

void setup()
{
LeftWheel_servo.attach(10);
RightWheel_servo.attach(11);
Serial.begin(9600);
pinMode(13,OUTPUT);
}

void loop()
{
float average_voltage;
delay(250);
average_voltage=get_average_v(20,0);
Serial.println(average_voltage);
average_voltage=get_average_v(20,0);
Serial.println(average_voltage);

while(average_voltage<1.52)
{
LeftWheel_servo.writeMicroseconds(1400);
RightWheel_servo.writeMicroseconds(1600);
}

start_time = millis();
elapsed_time = millis() - start_time;
Serial.println(elapsed_time);
while (elapsed_time<30000)

{
elapsed_time = millis() - start_time;
digitalWrite(analogPin, HIGH);
LeftWheel_servo.writeMicroseconds(1600);
RightWheel_servo.writeMicroseconds(1400);
}

while(1)
{
LeftWheel_servo.writeMicroseconds(1500);
RightWheel_servo.writeMicroseconds(1500);
}
}

float get_average_v(int num2avg, int channel)
{
int i;
float sum =0.0;
for (i=0; i<num2avg; i=i+1)
{
sum=sum+analogRead(channel);
}
sum=sum/num2avg;
sum=sum*5.0/1023.0;
return (sum);
}

Please use code tags, so your code looks like this:

int val= dist_sensor_V;

Where do you define dist_sensor_V?
What is the purpose of that line?

Welcome to the forum.

Its much easier to read your code if you use code tags

Like this

int val= dist_sensor_V;

In this case you are telling the computer "create a new variable called 'val' and assign it the value of 'dist_sensor_V'" but the computer is saying "I dont know anything about a variable called 'dist_sensor_V'"

So to solve your compile error you can say

int dist_sensor_V=0;
int val= dist_sensor_V;

But its not obvious why you need this at all since your code doesnt refer to either variable. You could simply delete the line.