Compilation error: expected constructor, destructor, or type conversion before '(' token

can you help me, i don't know what should i do..
Compilation error: expected constructor, destructor, or type conversion before '(' token

This is my code

pinMode(A0, INPUT);
Serial.begin(9600); // Starting Serial Terminal

Myservo.attach(5); // Signal Pin of Servo
pinMode(trigPin, OUTPUT); // Set trig pin as output
pinMode(echoPin, INPUT); // Set echo pin as input
pinMode(trigPin2, OUTPUT); // Set trig pin as output
pinMode(echoPin2, INPUT);

pinMode(12, OUTPUT);

Serial.print(" Distance ");
Serial.print(" Measurement ");

SIM900.begin(9600);
delay(2000);

}

void loop() {
//----------------------------------------Ultrasonic 1, mendeteksi tangan untuk handsanitizer
long duration, cm; // Declaring a variable

digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10); //To keep trig pin high for 10us
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH); //Taking input from echo pin
cm = microsecondsToCentimeters(duration);

Serial.print("Distance:");
Serial.print(cm);
Serial.print("cm");
delay(100);

if (cm >= 10) // Distance should be less than 10cm
{
Myservo.write(0); // Neutral Position of shaft
} else {
Myservo.write(90); // Turn left
}

Serial.print();
delay(100);

//----------------------------------------TMP36, cek suhu untuk buzzer
baselineTemp = 37.5;

celsius = map(((analogRead(A0) - 20) * 3.04), 0, 1023, -40, 125);
Serial.print(celsius);
Serial.print(" C, ");
if (celsius > baselineTemp) {
tone(9, 100, 1000); // Send 100 Hz sound signal
delay(0);
}

//----------------------------------------Ultrasonic 2, cek isi handsanitizer
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10); //To keep the trig pin high for 10us
digitalWrite(trigPin2, LOW);

duration = pulseIn(echoPin2, HIGH); //Taking input from echo pin
cm = microsecondsToCentimeters(duration);

Serial.print("Distance:");
Serial.print(cm);
Serial.print("cm");
delay(100);
if (cm <= 10) // Distance should be less than 10cm
{
SIM900.println("Handsanitizer Habis! Mohon diisi ulang! \n");
}
Serial.println();
delay(0);
}

long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2; // To convert microseconds to centimeters
}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

There is no setup() function in the sketch that you posted

then what should i add?

Look at any sketch, even the one that opens when you do File/New in the IDE

Every Arduino sketch must have at least a setup() and loop() function

Where did you get your code from ?

The posted code is incomplete. The first lines are missing. If you copied it from somewhere you didn't copy it complete.
The first lines in the code you posted belong to the setup function. But the lines before that that define global variables and the line that starts the setup function are missing.

You can't put these statements outside a function. Did you forget the:
`void setup() {'

@valisha ,

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

@valisha,
Again you have reported your own topic to the moderators. Why have you done this?

You are risking a ban from the forum.

Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.