Serial.read, Serial.find, general serial problems

I have a bot that started as an object avoid-er, I have since switched it to motion control via my android smart phone. Now I want to make it so I can switch between the two by pushing m for motion or a for avoidance. When I try to use the Serial.read or Serial.find it simply doesn't work. When I set the variable avoid to Serial.find("a"), it never switches just starts the loop over.

See the attached code. Any advice will be greatly appreciated.

NoAmarinoMotionControl.txt (8.48 KB)

        Serial.flush();

Block (wait) until all pending serial data has been sent. Why? Why do you think you need to do that?

        avoid =  Serial.find("19");

How does this relate to the Serial.print() that precedes it?

Suppose that the serial stream does contain "19". What will be stored in avoid? It behooves you to look it up, if you don't KNOW.

        if (avoid == '19')
        {
          availableSerial=0;
          autolistener();
        }
        else if(avoid =='m')
        {
           availableSerial = Serial.available(); 
        }

Hint: You are not even close.

By the way, which ONE key did you press to get that ONE character in the single quotes in the first statement?

See the attached code

Use the # code tag tool to post your code. many don't like the extra hassle of downloading and opening attachments.