Ultrasonic sensor and motor programming error

It is supposed to do the following: Output on the serial monitor the distance measurements from the HC-SR04 ultrasonic sensor (which it does do just fine), and set the A0 analog pin to HIGH so it powers on a motor plugged in when the distance measured is below a specific number.
This is the script…

// defines pins numbers
const int trigPin = 9;
const int echoPin = 10;

// defines variables
long duration;
int distance;

void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
pinMode(A0, OUTPUT);          // sets the analog pin A0 as output
}

void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);

// Calculating the distance
distance= duration*0.034/2;

// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);

if ("Distance" < 20) {digitalWrite(A0, HIGH);}
}

The error message is this:
warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if (“Distance” < (20)) {digitalWrite(A0, HIGH);}

What have I missed?
Thanks in advance…
*btw this is my first post on the forum, hope I formatted it correctly"

if (“Distance” < 20)

is a string constant. I believe you want to use your variable distance (without the quotes).

... and without a capital D.

That was it thank you :slight_smile: