' ' cannot be used as a function

hey everyone,

We have to build a vehicle, for our study, wich can find his way throug a labyrinth
We want to build this with 4 sonar sensors, to see the walls and can anticipate on to them, when they're too close.

We've written a program for this, it's not complete yet.

When i want to verify, it gives the error: 'SonarSensor' cannot be used as a function

Can someone help me with this? i don't know how to fix anymore.

the code:

#define trigPin1 3
#define echoPin1 2
#define trigPin2 4
#define echoPin2 5
#define trigPin3 7
#define echoPin3 8
#define ledPin 6
#define ledPinTwee 10
#define analogInPin A2
int ldrWaarde = 0;
int Var ;
char LastTurn ;
int SonarSensor ;
long duration, distance, RightSensor,BackSensor,FrontSensor,LeftSensor;

void setup()
{

Serial.begin (9600);
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
pinMode(trigPin3, OUTPUT);
pinMode(echoPin3, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(ledPinTwee,OUTPUT);
// roept de sonarsensor loop aan.
SonarSensor();
}

void loop() {

ldrWaarde = analogRead(analogInPin);

if (ldrWaarde > 900)
{
digitalWrite(ledPin,HIGH);
digitalWrite(ledPinTwee,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
digitalWrite(ledPinTwee,LOW);
}
Serial.println("LDR-waarde = ");
Serial.println(ldrWaarde);

delay(10);
do
{
SonarSensor(trigPin1, echoPin1);
RightSensor = distance;
SonarSensor(trigPin2, echoPin2);
LeftSensor = distance;
SonarSensor(trigPin3, echoPin3); // -- the error seems to be overhere
FrontSensor = distance;

Serial.print(LeftSensor);
Serial.print(" - ");
Serial.print(FrontSensor);
Serial.print(" - ");
Serial.println(RightSensor);
}

switch (//LDR-waarde en waarde sonars) {
case (FrontSensor < 2cm):
//do something when var equals 2
digitalWrite( ledPin,HIGH);
digitalWrite( ledPinTwee,HIGH);
delay (nog te bepalen);
break;
case (LeftSensor <2 , RightSensor >2):
//do something when var equals 2 -- rechtsom
digitalWrite( ledPin,HIGH);
digitalWrite( ledPinTwee,HIGH);//backwards
delay (nog te bepalen);
break;
case (LeftSensor >2 , RightSensor <2):
//do something when var equals 2 -- linksom
digitalWrite( ledPin,HIGH);//backwards
digitalWrite( ledPinTwee,HIGH);
delay (nog te bepalen);
break;
case LeftSensor <2,RightSensor <2:
do
{
digitalWrite( ledPin,HIGH);//backwards
digitalWrite( ledPinTwee,HIGH);
delay (nog te bepalen);
}
while(LastTurn = case (LeftSensor <2 , RightSensor >2)
case LeftSensor <2,RightSensor <2:
do
{
digitalWrite( ledPin,HIGH);
digitalWrite( ledPinTwee,HIGH);//backwards
delay (nog te bepalen);
}
while(LastTurn = case (LeftSensor >2 , RightSensor <2)
break;
case LeftSensor <2,RightSensor <2 FrontSensor <2:
//180 graden draaien
digitalWrite( ledPin,HIGH);
digitalWrite( ledPinTwee,HIGH);//backwards
delay (nog te bepalen);
break;
}
while(LdrWaarde > 900)

}

void SonarSensor(int trigPin,int echoPin)
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
}

Two things:
First, edit your post to use code tags. See How to use this forum. While you're at it, press CTRL+T in the IDE before copying it. Look better, doesn't it?

Second, the Arduino gives you more info then just that part of the error. For example, it tells you WHERE that error is. So please always copy the WHOLE error.

And a big tip, once you start numbering variables, arrays, always arrays... Makes life a lot easier :wink:

And what the...

switch (//LDR-waarde en waarde sonars) {
    case (FrontSensor < 2cm):

and

}
while(LastTurn = case (LeftSensor <2 , RightSensor >2)
       case LeftSensor <2,RightSensor <2:
    do

wuuuuuuuuut?! That's not how a switch statement works... No wonder my compiler doesn't even what to compile it! I would say, look it up :wink:

And for the error, a variable and a function may not have the same name :wink:

... and that is not how to check for equality.
= means set a value.
== means test for equality.

You also have do's without any following while's.

I suggest you learn the language before you write programs for it.