The program listen to messages from serial port in the form or where first character (A or D) means analog or digital, the 2nd character - pin, the 3rd character - 1/0 or from 0 to 255. The markers < and > show the beginning and the end of packet.
For example, if packet is received, the light is turned on by digitalWrite(13,1) But nothing happens. When I send via serial monitor, for instance: light is supposed to blink but it does not. The same with analogue outputs.
bool started = false;
bool ended = false;
char inData[5];
byte index;
void setup() 
{
  Serial.begin(9600);
}
void loop() 
{
  while (Serial.available() > 0)
  {
    char inChar = Serial.read();
    if (inChar == '<')
    {
      index = 0;
      started = true;
      ended = false; 
    }
    else if (inChar == '>')
    {
      ended = true;
      break;
    }
    else
    {
      if (index <= 4)
      {
        inData[index] = inChar;
        index++;
      }
    }
     if (started && ended)
    {
      if (inData[0] == 'A')
      {
        pinMode(inData[2],OUTPUT);
        analogWrite(inData[2],inData[4]);
      }
      else if (inData[0] == 'D')
      {
        if (inData[4] == 1)
        {
          pinMode(inData[2],OUTPUT);
          digitalWrite(inData[2],HIGH);
        }
        else if (inData[4] == 0)
        {
           pinMode(inData[2],OUTPUT);
           digitalWrite(inData[2],LOW);
        }
      }
      started = false;
      ended = false;
      index = 0; 
    }
  }
Serial.println("Sending");  
}
 
     
     
     
     
    