arduino nano connected to hc-sr04 error message

arduino nano connected to hc-sr04 error message

I keep getting an error message when I tried the code below.

const int TriggerPin = 7; //Trig pin
const int EchoPin = 8; //Echo pin
long Duration = 0;

void setup() {
// put your setup code here, to run once:
pinMode(TriggerPin, OUTPUT); // Trigger is an output pin
pinMode(EchoPin, INPUT); // Echo is an input pin
Serial.begin(9600); // Serial Output
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(TriggerPin, LOW);
delayMicroseconds(2);
digitalWrite(TriggerPin, HIGH); // Trigger pin to HIGH
delayMicroseconds(10); // 10us high
digitalWrite(TriggerPin, LOW); // Trigger pin to HIGH

Duration = pulseIn(EchoPin, HIGH); // Waits for the echo pin to get high
// returns the Duration in microseconds
long Distance_cm = Distance(Duration); // Use function to calculate the distance

Serial.print("Distance = "); // Output to serial
Serial.print(Distance_cm);
Serial.println(" cm");

delay(1000); // Wait to do next measurement
}
long Distance(long time)
{
long DistanceCalc; // Calculation variable

DistanceCalc = ((time * 0.034) / 2); // Actual calculation in cm
//DistanceCalc = time / 74 / 2; // Actual calculation in inches
return DistanceCalc; // return calculated value
}

Sketch uses 3144 bytes (10%) of program storage space. Maximum is 30720 bytes.
Global variables use 204 bytes (9%) of dynamic memory, leaving 1844 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
An error occurred while uploading the sketch




(deleted)