Programming problem I need both if else cases to work but only else loop is running #include &lt;SoftwareSerial.h&gt;
#include &lt;Servo.h&gt;
Servo myservo1, myservo2, myservo3;

int bluetoothTx = 14;
int bluetoothRx = 15;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
myservo1.attach(9);

//Setup usb serial connection to computer
Serial.begin(9600);

//Setup Bluetooth serial connection to android
bluetooth.begin(9600);
 }

void loop()
  {
    if(bluetooth.available()&gt;0)
     { 
      if(bluetooth.available()&gt;=4)
       {  
        char buffer[4];
          for(int i=0;i&lt;4;i++)
         {    
          buffer[i]=bluetooth.read();
         }
       int incomingValue = atoi(buffer);   

      if(incomingValue&gt;=1000 &amp;&amp; incomingValue&lt;=1360)
        {
           unsigned int servopos = bluetooth.read();
           unsigned int servopos1 = bluetooth.read();
           unsigned int realservo = (servopos1 * 256) + servopos;

         if (realservo &gt;= 1000 &amp;&amp; realservo &lt; 1360) 
          {
              int servo1 = realservo;
              servo1 = map(servo1, 1000, 1360, 0, 360);
              myservo1.write(servo1);
              Serial.println("servo 1 ON");
           delay(10);    
            }
           }
          }
         if(bluetooth.available()==2)
          {
            char inbit=bluetooth.read();  
            if(inbit=='A'||inbit=='D');
           {
            char myval= bluetooth.read();
            if(myval== 'A')
            {
              myservo1.attach(9);
            }


             if(myval== 'D')
              {
               myservo1.detach();
              }
             }     
            }
           }
          }
There are so many things wrong with that program I can't begin to sort it out.

Here's some of the most glaringly obvious errors:

if(bluetooth.read() &gt;=0 &amp;&amp; bluetooth.read() &lt;=360)


Read a character. Check it's at least 0. Read a second character. Check it's less than 360.  Since characters are between 0 and 255 that will always succeed if there is one character of any form to read (if there is no characters to read you get -1).

else if(bluetooth.read()=='A'||'B'||'C'||'D'||'E'||'F');


Read another character and compare it to 'A'. This if is true if the character read is A. It also succeeds if B, or if C or if D, etc. That's not "if it's equal to C", just "if C". C is a character literal, so it's equivalent to a number. Any number that is not 0 is TRUE, therefore it's equivalent to:

if character is A or TRUE or TRUE or TRUE...


Which of course is just true, so it will always succeed regardless.

char myval= bluetooth.read();
if(myval== 'A')


Read yet another character from bluetooth (I sure hope there are enough there...) then compare it to a list of characters that are the same as you looked at above. You're comparing a new character this time, not the one you compared with the list a few lines beforehand.