My ultrasonic SRF04 robot w\ IR sensor

ive recently made a basic ultrasonic robot from scartch. And used some libraries for the components (SRF04- i edited the NewPing library to work with IRRemote library, IR receiver- IRRemote) and im having some problems i cant figure out with my programe i was hoping to ask you if you the solution.

What im trying to do: As i said i made a basic ultrasonic robot and ive already made the basic code where he just walks around trying not to hit a wall. i made a function out of that called automatic(). And what im trying to do now is to make the robot move when i press a button on the remote wich i made function called manual() for his movement.

The problem: When i choose a mode i want ( either manual() or automatic() ) i stops looking for a button press it just repeats the operation no matter how much i press.

the code: https://codebender.cc/sketch:53862

When i choose a mode i want ( either manual() or automatic() ) i stops looking for a button press it just repeats the operation no matter how much i press.

Look at loop():

void loop()
{
 lookAround(); 
 if (Irrecv.decode(&results)) 
 {
  IRResults = results.value;
  switch (IRResults)
  {
    
   case  IROne:
   IRPrevious=IROne;
   while(resultFunct != 1)
   {
   automatic();
   }
   break;
   
   case IRTwo:
   IRPrevious=IRTwo;
   while(resultFunct != 1)
   {
   manual();
   }
   break;
    
  }
  Irrecv.resume(); // Receive the next value
  
  }

}

You got an IR value, but you have not (yet) reset the receiver to receiver another value, so the functions can not receive more data from the IR receiver.

You should have:

if (Irrecv.decode(&results)) 
 {
  IRResults = results.value;
 Irrecv.resume(); // Receive the next value
  
  }

followed by the code that uses IRResults. This way, the automatic() and manual() functions will be able to receive data from the IR receiver.

By the way, it's pointless to make a function return a global variable.

The functions return either 0 or 1 so the sketch know if it needs to repeat the function. If you have any tips on how i should do it id gladly improve it. Im pretty new to Arduino and programming in general

If you have any tips on how i should do it id gladly improve it.

It?

I showed you how to fix the problem of automatic() and manual() not being able to read IR data.

i meant if anyone has any tips on how i should improve my robot id id like to hear it