expected ')' before numeric constant

error message "expected ')' before numeric constant"

these are the codes
i have an ultrasonic sensor i want to make when distance <5 the led 9 light up :o

//code for testing Ultrasonic Module

#define ECHOPIN 3        // Pin to receive echo pulse
#define TRIGPIN 2        // Pin to send trigger pulse
#define Pin 9            // pin to LED Blink

void setup() {
  Serial.begin(9600);
  pinMode(ECHOPIN, INPUT);
  pinMode(TRIGPIN, OUTPUT);
  pinMode(9,OUTPUT);
}

void loop() {
 float distance = pulseIn(ECHOPIN, HIGH);
 distance= distance/58;
 
   Serial.print(distance);
 Serial.println(" cm");

 delay(200);
 
 // Start Ranging -Generating a trigger of 10us burst
 digitalWrite(TRIGPIN, LOW);
 delayMicroseconds(2);
 digitalWrite(TRIGPIN, HIGH);
 delayMicroseconds(10);
 digitalWrite(TRIGPIN, LOW);

 if (distance < 5); {
 
 digitalWrite(Pin 9, LOW);
 delay(50);
 digitalWrite(Pin 9,HIGH);
 delay(50)
}
else
{
 digitalWrite(Pin 9, LOW)
}

/* The speed of sound is 340 m/s or 29 us per cm.The Ultrasonic burst travels out & back.So to find the distance of object we divide by 58 */

 if (distance < 5); {

That semicolon looks suspicious.

So does the fact that loop() is missing a closing curly brace.

The error message YOU saw showed the line number. Why are you keeping that secret?

By the way, you need to diddle with the trigger pin BEFORE you call pulseIn() to read an echo.

Thanks for trying to use code tags but they should go before and after the code as in Paul's post

Why do you need to write this low

digitalWrite(TRIGPIN, LOW);
delayMicroseconds(2);

Isn't it already low from the write that occurred in the prior cycle?

delayMicroseconds(10);
digitalWrite(TRIGPIN, LOW);

(I fixed your code tags also)

 if (distance < 5) {
 
 digitalWrite(Pin 9, LOW);
 delay(50);
 digitalWrite(Pin 9,HIGH);
 delay(50)

What is "Pin " doing there?

//code for testing Ultrasonic Module

#define ECHOPIN 3        // Pin to receive echo pulse
#define TRIGPIN 2        // Pin to send trigger pulse
#define Pin 9            // pin to LED Blink

void setup() {
  Serial.begin(9600);
  pinMode(ECHOPIN, INPUT);
  pinMode(TRIGPIN, OUTPUT);
  pinMode(9,OUTPUT);
}

void loop() {
 // Start Ranging -Generating a trigger of 10us burst
 
 digitalWrite(TRIGPIN, HIGH);
 delayMicroseconds(10);
 digitalWrite(TRIGPIN, LOW);
 float distance = pulseIn(ECHOPIN, HIGH); // pulseIn returns microseconds, an unsigned long
 distance= distance/58;
 
   Serial.print(distance);
 Serial.println(" cm");

 delay(200);
 
 if (distance < 5) {
 
 digitalWrite(Pin 9, LOW);
 delay(50);
 digitalWrite(Pin 9,HIGH);
 delay(50)
}
else
{
 digitalWrite(Pin 9, LOW)
}
} // end of loop

How does knowing how long the returned pulse is high tell you distance?
I would think you'd need to measure from the time you sent the pulse to the time you saw the pulse return to get a distance. So you really want edge detection, not width detection, yes?

[/code]

CrossRoads:
How does knowing how long the returned pulse is high tell you distance?

That's how the HC-SR04 ultrasonic rangefinders work. They delay the start of the Echo pulse a few microseconds to allow time for the pulseIn() call. Then when the echo arrives they delay the end of the Echo pulse the same amount. The old Paralax "PING)))" sensor works the same but uses a single pin for both input and output.