I got this error avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0

int In1 =7; //the number of L298n h bridge
int In2 =8; // the number of L298n h bridge
int ENA =5; //the number of L298n h bridge
int SPEED =210;
int potVal = A0; // the number of the potentiometer pin

const int pushButton =9; // the number of the pushbutton pin
const int swi_pos2 =11; // the number of the selector switch pin
const int swi_pos3 =12; // the number of the selector switch pin
const int swi_pos4 =13; // the number of the selector switch pin

// variables will change:
int pushState=0 ;
int slecSwitch2= 0;
int slecSwitch3= 0 ;
int slecSwitch4 =0;

void setup()
{
int potVal = analogRead(A0); // Read potentiometer value
int SPEED = map(potVal,0,1023 , 0 , 255); // Map the potentiometer value from 0 to 255
analogWrite(ENA, SPEED); // Send PWM signal to L298N Enable pin

// put your setup code here, to run once:
pinMode (In1 , OUTPUT);
pinMode (In2 , OUTPUT);
pinMode (ENA , OUTPUT);
pinMode(pushButton, INPUT);
pinMode (swi_pos2, INPUT);
pinMode (swi_pos3, INPUT);
pinMode (swi_pos4, INPUT);
}

void loop()
{
pushState = digitalRead (pushButton);
slecSwitch2 = digitalRead (swi_pos2);
slecSwitch3 = digitalRead (swi_pos3);
slecSwitch4 = digitalRead (swi_pos4);

// put your main code here, to run repeatedly:
if ( pushState == HIGH && slecSwitch2 == HIGH)
{
// delay(2000);
digitalWrite(In2,HIGH); // turn direction for forward direction
digitalWrite(In1,LOW);//motor voltage on
}

if ( pushState == HIGH && slecSwitch3 == HIGH)
{
delay(2000);
digitalWrite(In2,LOW); // turn direction for reverse direction
digitalWrite(In1,HIGH);//motor voltage on
}
if ( pushState == HIGH && slecSwitch4 == HIGH)
{
delay(2000);
digitalWrite(In2,LOW); // turn direction for reverse direction(ultrasonic sensor)
digitalWrite(In1,HIGH);//motor voltage on
}

}

Has nothing to do with the sketch, either you have not selected the correct board or the correct port (or something else related to uploading eg no reset or not in flashmode)

Is this the first time that you used the biard? Or did the problem suddenly start?

Which board? Clone or original? In case of the former, you might need to install the CH340 driver.