Code Error

I don’t understand what this mean and how to fix it.

int target()

{
long duration = 0;
long distance = 0;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration * 0.0343) / 2;
return distance;
}

expected initializer before ‘int’

I don’t understand what this mean and how to fix it.

Post your code, in code tags, and we’ll try to help you fix it

Where is code tags again.

arduinoproblems:
Where is code tags again.

[code][/code]

int target()

{
long duration = 0;
long distance = 0;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration * 0.0343) / 2;
return distance;
}

error
exit status 1
expected initializer before 'int'

Yes, that’s just the same snippet you posted, equally badly, last time.

i put in the code tags but i don't know how to fix it.

arduinoproblems:
i put in the code tags but i don’t know how to fix it.

No, you clearly didn’t

Where is the rest of your code?

#define trigPin 7
#define echoPin 6
int tank =0;
int phase =0;
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(2, INPUT);
analogWrite(11, 240);
analogWrite(10, 255);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
}

int target()

{
long duration = 0;
long distance = 0;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration * 0.0343) / 2;
return distance;
}
same error.

I only get “undefined reference to `loop’”, but that didn’t surprise me.

Please remember to use code tags when posting code.