ISO C++ error

i’m making a robot with bluetooth but i got a problem
I get this error: ISO C++ forbids comparison between pointer and integer
what is wrong?

else if (checkleft <=30 && checkright <=30){
achteruit();
linksaf();
}

BLuetooth_Control.ino (3.68 KB)

Please post your code inline and the complete error message in code-tags next time. And press ctrl+t for fun and see how much better that looks :wink:

And worst, post all the code! Because my error message is that ultrasonic was not declared. So what did happen to it?

But as the error tells you, something is a integer and something is a pointer :wink: But without the real code it's hard to say more...

tvamersfoorth:
what is wrong?

Most likely: Variable declaration and usage in your code is wrong!

checkleft and checkright seem to be pointers in your code, but you compare against int-value 30 and not against a pointer value.

You don’t try to compare the address of declared functions against integer number, don’t you?

In case checkleft and checkright identifiers refer to function names of functtions with an int as the return value , try that calling the functions and comparing the int return values instead of comparring the function pointers:

if (checkleft() <=30 && checkright() <=30)

But we'll just have to guess...

In his code checkleft and chachright are int's. But then again, he tries to fill them with a method of some non-existing ultrasonic object... ::slight_smile:

void loop()
{
      
        if (Serial.available() > 0)
        digitalWrite(trigPin, HIGH);
        delayMicroseconds(10);
        digitalWrite(trigPin, LOW);
        duration = pulseIn(echoPin, HIGH);
        distance = (duration/2)/29.1;
        Serial.print(distance);
        Serial.println("cm");
        data = Serial.read();       
        Serial.print(data);     
        Serial.print("\n");

Why do you turn the trigger pin on only if there is serial data that hasn't been read?

After commenting out the two calls to ultrasonic.Ranging() in your code, your code compiles for me.

septillion:
But we’ll just have to guess…

In his code checkleft and chachright are int’s. But then again, he tries to fill them with a method of some non-existing ultrasonic object… ::slight_smile:

Oh, I see: the line of code he posted “if (checkleft <=30 && checkright <=30)” is NOT the line causing the compile error.

Very strange to open a New Topic then and claiming that “if (checkleft <=30 && checkright <=30)” is causing a compile error while the eason of the compile error is in a different line.