range finder with LED and buzzer

Hello all
I have a problem. I am making a range finder and if the distance is less than 10 cm a red LED should light up and the buzzer should make a noise, but I get an error message in my code. can anyone help me?
(if the adstand is larger than 10 cm, a green LED lights up)
thank you in advance
Kind regards
Cisse

[#include <LiquidCrystal.h>

LiquidCrystal lcd(1, 2, 4, 5, 6, 7);

const int trigPin = 9;
const int echoPin = 10;
long duration;
int distanceCm, distanceInch;

void setup() {

lcd.begin(16,2);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(11, OUTPUT);
}

void loop() {

digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distanceCm= duration0.036/2;
distanceInch = duration
0.0133/2;

lcd.setCursor(0,0);
lcd.print("Distance: ");
lcd.print(distanceCm);
lcd.print(" cm");
delay(10);
lcd.setCursor(0,1);
lcd.print("Distance: ");
lcd.print(distanceInch);
lcd.print("inch");
delay(10);
if(distanceCm ==<10) // here is the error message
digitalWrite(12, HIGH); // red LED turns on
digitalWrite(11, HIGH);// buzzer turns on
digitalWrite(13, LOW);// green LED turn off
else(
digitalWrite(12, LOW);// red LED turns off
noTone(13);// buzzer turns off
digitalWrite(13, HIGH);// green LED turn on
)
}

if(distanceCm ==<10)

How can something be equal and less than?

Then you're going to have problems with () when you should have {}.
And no {} when you should have {}.

Please remember to use code tags when posting code.

the distance has to be minus 10 so I need to delete the "=="?
and can you pls explain what you mean with the {} and ()?

if(distanceCm <10) // here it looks like you want
digitalWrite(12, HIGH); // all these line to be part 
digitalWrite(11, HIGH);// of the conditional block,
digitalWrite(13, LOW);// but they're not.

You need to enclose them in a pair of these { }

else(
  digitalWrite(12, LOW);// red LED turns off
  noTone(13);// buzzer turns off
  digitalWrite(13, HIGH);// green LED turn on
)

Here you shouldn't use ( ), you should use { }

okay thanks for the help and I will remember not to just put the code in the text

hello
can someone help me with this error message?
pls also tell me if I do something else wrong.

this is te message:exit status 1
expected '(' before '{' token
#include <LiquidCrystal.h>

LiquidCrystal lcd(1, 2, 4, 5, 6, 7); 

const int trigPin = 9;
const int echoPin = 10;
long duration;
int distanceCm, distanceInch;

void setup() {
  
lcd.begin(16,2); 
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(11, OUTPUT);
}

void loop() {
  
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distanceCm= duration*0.036/2;
distanceInch = duration*0.0133/2;                        

lcd.setCursor(0,0); 
lcd.print("Distance: "); 
lcd.print(distanceCm); 
lcd.print("  cm");
delay(10);
lcd.setCursor(0,1);
lcd.print("Distance: ");
lcd.print(distanceInch);
lcd.print("inch");
delay(10);
if{(distanceCm <10) // here is the error message
digitalWrite(12, HIGH); // red LED turns on
digitalWrite(11, HIGH);// buzzer turns on
digitalWrite(13, LOW);// green LED turn off
}
else{
  digitalWrite(12, LOW);// red LED turns off
  noTone(13);// buzzer turns off
  digitalWrite(13, HIGH);// green LED turn on
}
}
if{(distanceCm <10)

What do I need to do?

You need to study the syntax for if()

thanks for the tip!! :wink: