HELP

Help with ISO C++ forbids comparison between pointer and integer.
I have a problem any one can help please, I'm very smart but i'm young and cant find an answer. hear is my code

if( FLOW == 2)<---------the part im getting the problem at.

void FLOW (int Flow)
{
if (digitalRead(buttonPin))
{
Flow = 1;
}

if (digitalRead(buttonPin2))
{
Flow = 2;
}
}

as much as I want to show, will show if need be.

Hello and welcome,

That condition (once fixed by adding () :slight_smile: ) will never be true because your function doesn't return anything.

You have to do something like this:

if( FLOW() == 2 )
{
  //do something when FLOW() returns 2
}

...

int FLOW()
{
  if (digitalRead(buttonPin))
  {
    return 1;
  }

  else if (digitalRead(buttonPin2))
  {
    return 2;
  }

  return 0;
}

Also don't double post, click the Remove button near your posts in the other topic, write a clear topic title not just "HELP"... and use code tags (the '#' button) around your code :slight_smile:

how should i change the code to fix it.

Deion:
how should i change the code to fix it.

Start by explaining what you are trying to do.

Read this before posting a programming question

Very useless thread title. Everyone wants help. Try being more specific.

if( FLOW == 2)<---------the part im getting the problem at.

void FLOW (int Flow)
{
  if (digitalRead(buttonPin))
  {
    Flow = 1;
  }

  if (digitalRead(buttonPin2))
  {
   Flow = 2;
  }
}

Try guix code

void loop()
{
  if( FLOW() == 2 )
  {
    //do something when FLOW() returns 2
  }

  else if( FLOW() == 1 )
  {
    //do something when FLOW() returns 1
  }

  else
  {
    //do something when FLOW() returns 0
  }
}


int FLOW()
{
  if (digitalRead(buttonPin))
  {
    return 1;
  }

  else if (digitalRead(buttonPin2))
  {
    return 2;
  }

  return 0;
}

Having a variable and a function with the same name is a recipe for disaster. Function names should imply what they do. FLOW() does not. Give the function a meaningful name, and do not declare it inside the if statement, and life will be better.