Need help on this programm

I want to use the option button 1, to read the next function. Where it will read the motor to run at low speed. While button 2 to high speed. Can anyone detect my error in the coding... Thank you.

#include "IRremote.h"

//L293D
//Motor A
const int motorPin1 = 9; // Pin 14 of L293
const int motorPin2 = 10; // Pin 10 of L293

int time0;

int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11

/-----( Declare objects )-----/
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'

void setup() /----( SETUP: RUNS ONCE )----/
{
Serial.begin(9600);
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
Serial.println("IR Receiver Button Decode");
irrecv.enableIRIn(); // Start the receiver

}/--(end setup )---/
void loop() /----( LOOP: RUNS CONSTANTLY )----/
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
translateIR();
irrecv.resume(); // receive the next value
}
}/* --(end main loop )-- */

/-----( Function )-----/
void translateIR() // takes action based on IR code received

//L293D
//Motor A

// describing Remote IR codes
{
switch(results.value)
{
case 0xFF6897: Serial.println("(0) 0");break;
case 0xFF30CF: Serial.println("(1) 1");break;
case 0xFF18E7: Serial.println("(2) 2");break;
case 0xFF7A85: Serial.println("(3) 3");break;
default:
Serial.println(" other button ");
while (!Serial.available());

while (!Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{
if (c == '0')
analogWrite(motorPin1, 0);
analogWrite(motorPin2, 0);
delay(5000);
if (c == '1')
analogWrite(motorPin1, 100);
analogWrite(motorPin2, 0);
delay(5000);
if (c == '2')
analogWrite(motorPin1, 200);
analogWrite(motorPin2, 0);
delay(5000);
}
else
{
Serial.println(F("wrong input"));
return 0;
}
time0 = millis();
return c;
}
}
}// End Case
}

Moved your topic to a mores suitable section.

Other post/duplicate DELETED

Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

You may want to READ THIS for future reference.
It will help you get the best out of the forum.

Bob.

Can anyone detect my error in the coding

Maybe you could give us a clue to the problem. Does the code compile? If not, what is the error (post the complete text of the error). Otherwise describe what the code actually does and how that differs from what you want it to do.

Before posting your code, in code tags, use the IDE autoformat tool to indent your code to make it easier to follow.

LadyZura:
I want to use the option button 1, to read the next function. Where it will read the motor to run at low speed. While button 2 to high speed. Can anyone detect my error in the coding... Thank you.

      while (!Serial.available())
      {
        char c = Serial.read();

This is a problem. You are only reading characters when there are none to read.

        if (isAlphaNumeric(c))
        {
          if (c == '0')
            analogWrite(motorPin1, 0);
            analogWrite(motorPin2, 0);
            delay(5000);
          if (c == '1')
            analogWrite(motorPin1, 100);
            analogWrite(motorPin2, 0);
            delay(5000);
          if (c == '2')
            analogWrite(motorPin1, 200);
            analogWrite(motorPin2, 0);
            delay(5000);
        }

Unlike Python, just indenting the same doesn't make statements part of a block. You need brackets:

        if (isAlphaNumeric(c))
        {
          if (c == '0')
          {
            analogWrite(motorPin1, 0);
            analogWrite(motorPin2, 0);
            delay(5000);
          }
          if (c == '1')
          {
            analogWrite(motorPin1, 100);
            analogWrite(motorPin2, 0);
            delay(5000);
          }
          if (c == '2')
          {
            analogWrite(motorPin1, 200);
            analogWrite(motorPin2, 0);
            delay(5000);
          }
        }