Skip to main content
added 28 characters in body
Source Link
gre_gor
  • 1.7k
  • 4
  • 18
  • 30

where 
REG is A - K (the registers in the ARD 2650) 
COMMAND can be a 2-chars command, but mostly 1-char commands.

EG:  AR:255<cr>  // AR configures DDRA to out- or in-put , depending on the parameter - (here 255 / 0xff) .

AI:0<cr>  Read port A input (actually return content of ARD2560 port A inputregisterinput register)
   
AO:<number><CR>   Send Number to port A (and return result to D-7 ).

......

All those command are valid for RegReg A to Reg K.

 if (char (pport[0] == '*' ))  // '*' can be 'A' to 'K' 

the responsetime increases to appr. 2 sec's .

 if (char (pport[0] == '*' ))  // '*' can be 'A' to 'K' 

(sorry there's no comment !) The response time increases to appr. 2 seconds.

Thanks for Any help.(sorry that there are no comments!)

here'sHere's the Codecode:

#include <Esplora.h>

void setup()
{
    Serial.begin(9600);
}

void loop()
{

String chr;

  if (Serial.available() > 0)
  {
    String pport = Serial.readStringUntil(':');
    {
      String pos = Serial.readStringUntil('\n');

      if (char (pport[0] == 'A' ))        /* A */
      {
        if (pport == "AR")
        {
          DDRA = pos.toInt();
          DOCRLF("//AR+", pos.toInt());
        }
        else
        if (pport == "AI")
        {
          if (DDRA == B00000000)
          {
            Serial.print(PORTA);
            chr = "//AI";
          }
          else
          {
            chr ="//AI-";
          }
          DOCRLF(chr , pos.toInt());
        }
        else
        if (pport == "AO")
        {
          if (DDRA == B11111111)
          {
            PORTA = pos.toInt();
            chr = "//AO+";
          }
          else
          {
            chr = "//AO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "AU")
        {
          Serial.print(PORTA);
          DOCRLF("//AU+", pos.toInt());
        }
        else
        if (pport == "ABW")
        {
          PORTA = pos.toInt();
          DOCRLF("//ABW+", pos.toInt());
        }
        else
        if (pport == "ABR")
        {
          Serial.print(PORTA);
          DOCRLF("//ABR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'B' ))        /* B */
      {
        if (pport == "BR")
        {
          DDRB = pos.toInt();
          DOCRLF("//BR+", pos.toInt());
        }
        else
        if (pport == "BI")
        {
          if (DDRB == B00000000)
          {
            Serial.print(PORTB);
            chr = "//BI+";
          }
          else
          {
            chr = "//BI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "BO")
        {
          if (DDRB == B11111111)
          {
            PORTB = pos.toInt();
            chr = "//BO+";
          }
          else
          {
            chr = "//BO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "BU")
        {
          Serial.print(PORTB);
          DOCRLF("//BU+", pos.toInt());
        }
        else
        if (pport == "BBW")
        {
          PORTB = pos.toInt();
          DOCRLF("//EBW+", pos.toInt());
        }
        else
        if (pport == "BBR")
        {
          Serial.print(PORTB);
          DOCRLF("//BBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'C' ))        /* C */
      {
        if (pport == "CR")
        {
          DDRC = pos.toInt();
          DOCRLF("//CR+", pos.toInt());
        }
        else
        if (pport == "CI")
        {
          if (DDRC == B00000000)
          {
            Serial.print(PORTC);
            chr = "//CI+";
          }
          else
          {
            chr = "//CI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "CO")
        {
          if (DDRC == B11111111)
          {
            PORTC = pos.toInt();
            chr = "//CO+";
          }
          else
          {
            chr = "//CO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "CU")
        {
          Serial.print(PORTC);
          DOCRLF("//CU+", pos.toInt());
        }
        else
        if (pport == "CBW")
        {
          PORTC = pos.toInt();
          DOCRLF("//CBW+", pos.toInt());
        }
        else
        if (pport == "CBR")
        {
          Serial.print(PORTC);
          DOCRLF("//CBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'D' ))        /* D */
      {
        if (pport == "DR")
        {
          DDRD = pos.toInt();
          DOCRLF("//DR+", pos.toInt());
        }
        else
        if (pport == "DI")
        {
          if (DDRD == B00000000)
          {
            Serial.print(PORTD);
            chr = "//DI+";
          }
          else
          {
            chr = "//DI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "DO")
        {
          if (DDRD == B11111111)
          {
            PORTD = pos.toInt();
            chr = "//DO+";
          }
          else
          {
            chr = "//DO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "DU")
        {
          Serial.print(PORTD);
          DOCRLF("//DU+", pos.toInt());
        }
        else
        if (pport == "DBW")
        {
          PORTD = pos.toInt();
          DOCRLF("//DBW+", pos.toInt());
        }
        else
        if (pport == "DBR")
        {
          Serial.print(PORTE);
          Serial.println("//DBR+");
        }
      }
      else
      if (char (pport[0] == 'E' ))        /* E */
      {
        if (pport == "ER")
        {
          DDRE = pos.toInt();
          DOCRLF("//ER+", pos.toInt());
        }
        else
        if (pport == "EI")
        {
          if (DDRE == B00000000)
          {
            Serial.print(PORTE);
            chr = "//ER+";
          }
          else
          {
            chr = "//ER-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "EO")
        {
          if (DDRE == B11111111)
          {
            PORTE = pos.toInt();
            chr = "//EO+";
          }
          else
          {
            chr = "//EO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "EU")
        {
          Serial.print(PORTE);
          DOCRLF("//EU+", pos.toInt());
        }
        else
        if (pport == "EBW")
        {
          PORTE = pos.toInt();
          DOCRLF("//EBW+", pos.toInt());
        }
        else
        if (pport == "EBR")
        {
          Serial.print(PORTE);
          DOCRLF("//EBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'F' ))        /* F */
      {
        if (pport == "FR")
        {
          DDRF = pos.toInt();
          DOCRLF("//FR+", pos.toInt());
        }
        else
        if (pport == "FI")
        {
          if (DDRF == B00000000)
          {
            Serial.print(PORTF);
            chr = "//FI+";
          }
          else
          {
            chr = "//F1-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "FO")
        {
          if (DDRF == B11111111)
          {
            PORTF = pos.toInt();
            chr = "//FO+";
          }
          else
          {
            chr = "//FO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "FU")
        {
          Serial.print(PORTF);
          DOCRLF("//FU+", pos.toInt());
        }
        else
        if (pport == "FBW")
        {
          PORTF = pos.toInt();
          DOCRLF("//FBW+", pos.toInt());
        }
        else
        if (pport == "FBR")
        {
          Serial.print(PORTF);
          DOCRLF("//FBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'G' ))        /* G */
      {
        if (pport == "GR")
        {
          DDRG = pos.toInt();
          DOCRLF("//GR+", pos.toInt());
        }
        else
        if (pport == "GI")
        {
          if (DDRG == B00000000)
          {
            Serial.print(PORTG);
            chr = "//GI+";
          }
          else
          {
            chr = "//GI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "GO")
        {
          if (DDRG == B11111111)
          {
            PORTG = pos.toInt();
            chr = "//GO+";
          }
          else
          {
            chr = "//GO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "GU")
        {
          Serial.print(PORTG);
          DOCRLF("//GU+", pos.toInt());
        }
        else
        if (pport == "GBW")
        {
          PORTG = pos.toInt();
          DOCRLF("//GBW+", pos.toInt());
        }
        else
        if (pport == "GBR")
        {
          Serial.print(PORTG);
          DOCRLF("//GBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'H' ))        /* H */
      {
        if (pport == "HR")
        {
          DDRH = pos.toInt();
          DOCRLF("//HR+", pos.toInt());
        }
        else
        if (pport == "HI")
        {
          if (DDRH == B00000000)
          {
            Serial.print(PORTH);
            chr = "//HI+";
          }
          else
          {
            chr = "//HI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "HO")
        {
          if (DDRH == B11111111)
          {
            PORTH = pos.toInt();
            chr = "//HO+";
          }
          else
          {
            chr = "//HO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "HU")
        {
          Serial.print(PORTH);
          DOCRLF("//HU+", pos.toInt());
        }
        else
        if (pport == "HBW")
        {
          PORTH = pos.toInt();
          DOCRLF("//HBW+", pos.toInt());
        }
        else
        if (pport == "HBR")
        {
          Serial.print(PORTH);
          DOCRLF("//HBR+", pos.toInt());
        }
      }
      else
      if (pport == "RA")
      {
        int aport = (pos.toInt());

        if (aport > -1 && aport < 16)
        {
          Serial.println (" OK ");
        }
      }
      else
      if (pport == "KO")
      {
        Serial.print("//KO+");
        if (DDRA == B11111111)
        {
           Serial.print("A");
        }
        else
        {
           Serial.print("a");
        }
        if (DDRB == B11111111)
        {
           Serial.print("B");
        }
        else
        {
           Serial.print("b");
        }
        if (DDRC == B11111111)
        {
           Serial.print("C");
        }
        else
        {
           Serial.print("c");
        }
        if (DDRD == B11111111)
        {
           Serial.print("D");
        }
        else
        {
           Serial.print("d");
        }
        if (DDRE == B11111111)
        {
           Serial.print("E");
        }
        else
        {
           Serial.print("e");
        }
        if (DDRF == B11111111)
        {
           Serial.print("F");
        }
        else
        {
           Serial.print("f");
        }
        if (DDRG == B11111111)
        {
           Serial.print("G");
        }
        else
        {
           Serial.print("g");
        }
        if (DDRH == B11111111)
        {
           Serial.print("H");
        }
        else
        {
           Serial.print("h");
        }
        Serial.println();
      }
    }
  }
}

void DOCRLF (String txt, int vval)
{
  Serial.print(txt);
  Serial.println(vval);
}
#include <Esplora.h>

void setup()
{
    Serial.begin(9600);
}

void loop()
{

  String chr;

  if (Serial.available() > 0)
  {
    String pport = Serial.readStringUntil(':');
    {
      String pos = Serial.readStringUntil('\n');

      if (char (pport[0] == 'A' ))        /* A */
      {
        if (pport == "AR")
        {
          DDRA = pos.toInt();
          DOCRLF("//AR+", pos.toInt());
        }
        else
        if (pport == "AI")
        {
          if (DDRA == B00000000)
          {
            Serial.print(PORTA);
            chr = "//AI";
          }
          else
          {
            chr ="//AI-";
          }
          DOCRLF(chr , pos.toInt());
        }
        else
        if (pport == "AO")
        {
          if (DDRA == B11111111)
          {
            PORTA = pos.toInt();
            chr = "//AO+";
          }
          else
          {
            chr = "//AO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "AU")
        {
          Serial.print(PORTA);
          DOCRLF("//AU+", pos.toInt());
        }
        else
        if (pport == "ABW")
        {
          PORTA = pos.toInt();
          DOCRLF("//ABW+", pos.toInt());
        }
        else
        if (pport == "ABR")
        {
          Serial.print(PORTA);
          DOCRLF("//ABR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'B' ))        /* B */
      {
        if (pport == "BR")
        {
          DDRB = pos.toInt();
          DOCRLF("//BR+", pos.toInt());
        }
        else
        if (pport == "BI")
        {
          if (DDRB == B00000000)
          {
            Serial.print(PORTB);
            chr = "//BI+";
          }
          else
          {
            chr = "//BI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "BO")
        {
          if (DDRB == B11111111)
          {
            PORTB = pos.toInt();
            chr = "//BO+";
          }
          else
          {
            chr = "//BO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "BU")
        {
          Serial.print(PORTB);
          DOCRLF("//BU+", pos.toInt());
        }
        else
        if (pport == "BBW")
        {
          PORTB = pos.toInt();
          DOCRLF("//EBW+", pos.toInt());
        }
        else
        if (pport == "BBR")
        {
          Serial.print(PORTB);
          DOCRLF("//BBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'C' ))        /* C */
      {
        if (pport == "CR")
        {
          DDRC = pos.toInt();
          DOCRLF("//CR+", pos.toInt());
        }
        else
        if (pport == "CI")
        {
          if (DDRC == B00000000)
          {
            Serial.print(PORTC);
            chr = "//CI+";
          }
          else
          {
            chr = "//CI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "CO")
        {
          if (DDRC == B11111111)
          {
            PORTC = pos.toInt();
            chr = "//CO+";
          }
          else
          {
            chr = "//CO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "CU")
        {
          Serial.print(PORTC);
          DOCRLF("//CU+", pos.toInt());
        }
        else
        if (pport == "CBW")
        {
          PORTC = pos.toInt();
          DOCRLF("//CBW+", pos.toInt());
        }
        else
        if (pport == "CBR")
        {
          Serial.print(PORTC);
          DOCRLF("//CBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'D' ))        /* D */
      {
        if (pport == "DR")
        {
          DDRD = pos.toInt();
          DOCRLF("//DR+", pos.toInt());
        }
        else
        if (pport == "DI")
        {
          if (DDRD == B00000000)
          {
            Serial.print(PORTD);
            chr = "//DI+";
          }
          else
          {
            chr = "//DI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "DO")
        {
          if (DDRD == B11111111)
          {
            PORTD = pos.toInt();
            chr = "//DO+";
          }
          else
          {
            chr = "//DO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "DU")
        {
          Serial.print(PORTD);
          DOCRLF("//DU+", pos.toInt());
        }
        else
        if (pport == "DBW")
        {
          PORTD = pos.toInt();
          DOCRLF("//DBW+", pos.toInt());
        }
        else
        if (pport == "DBR")
        {
          Serial.print(PORTE);
          Serial.println("//DBR+");
        }
      }
      else
      if (char (pport[0] == 'E' ))        /* E */
      {
        if (pport == "ER")
        {
          DDRE = pos.toInt();
          DOCRLF("//ER+", pos.toInt());
        }
        else
        if (pport == "EI")
        {
          if (DDRE == B00000000)
          {
            Serial.print(PORTE);
            chr = "//ER+";
          }
          else
          {
            chr = "//ER-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "EO")
        {
          if (DDRE == B11111111)
          {
            PORTE = pos.toInt();
            chr = "//EO+";
          }
          else
          {
            chr = "//EO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "EU")
        {
          Serial.print(PORTE);
          DOCRLF("//EU+", pos.toInt());
        }
        else
        if (pport == "EBW")
        {
          PORTE = pos.toInt();
          DOCRLF("//EBW+", pos.toInt());
        }
        else
        if (pport == "EBR")
        {
          Serial.print(PORTE);
          DOCRLF("//EBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'F' ))        /* F */
      {
        if (pport == "FR")
        {
          DDRF = pos.toInt();
          DOCRLF("//FR+", pos.toInt());
        }
        else
        if (pport == "FI")
        {
          if (DDRF == B00000000)
          {
            Serial.print(PORTF);
            chr = "//FI+";
          }
          else
          {
            chr = "//F1-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "FO")
        {
          if (DDRF == B11111111)
          {
            PORTF = pos.toInt();
            chr = "//FO+";
          }
          else
          {
            chr = "//FO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "FU")
        {
          Serial.print(PORTF);
          DOCRLF("//FU+", pos.toInt());
        }
        else
        if (pport == "FBW")
        {
          PORTF = pos.toInt();
          DOCRLF("//FBW+", pos.toInt());
        }
        else
        if (pport == "FBR")
        {
          Serial.print(PORTF);
          DOCRLF("//FBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'G' ))        /* G */
      {
        if (pport == "GR")
        {
          DDRG = pos.toInt();
          DOCRLF("//GR+", pos.toInt());
        }
        else
        if (pport == "GI")
        {
          if (DDRG == B00000000)
          {
            Serial.print(PORTG);
            chr = "//GI+";
          }
          else
          {
            chr = "//GI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "GO")
        {
          if (DDRG == B11111111)
          {
            PORTG = pos.toInt();
            chr = "//GO+";
          }
          else
          {
            chr = "//GO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "GU")
        {
          Serial.print(PORTG);
          DOCRLF("//GU+", pos.toInt());
        }
        else
        if (pport == "GBW")
        {
          PORTG = pos.toInt();
          DOCRLF("//GBW+", pos.toInt());
        }
        else
        if (pport == "GBR")
        {
          Serial.print(PORTG);
          DOCRLF("//GBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'H' ))        /* H */
      {
        if (pport == "HR")
        {
          DDRH = pos.toInt();
          DOCRLF("//HR+", pos.toInt());
        }
        else
        if (pport == "HI")
        {
          if (DDRH == B00000000)
          {
            Serial.print(PORTH);
            chr = "//HI+";
          }
          else
          {
            chr = "//HI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "HO")
        {
          if (DDRH == B11111111)
          {
            PORTH = pos.toInt();
            chr = "//HO+";
          }
          else
          {
            chr = "//HO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "HU")
        {
          Serial.print(PORTH);
          DOCRLF("//HU+", pos.toInt());
        }
        else
        if (pport == "HBW")
        {
          PORTH = pos.toInt();
          DOCRLF("//HBW+", pos.toInt());
        }
        else
        if (pport == "HBR")
        {
          Serial.print(PORTH);
          DOCRLF("//HBR+", pos.toInt());
        }
      }
      else
      if (pport == "RA")
      {
        int aport = (pos.toInt());

        if (aport > -1 && aport < 16)
        {
          Serial.println (" OK ");
        }
      }
      else
      if (pport == "KO")
      {
        Serial.print("//KO+");
        if (DDRA == B11111111)
        {
           Serial.print("A");
        }
        else
        {
           Serial.print("a");
        }
        if (DDRB == B11111111)
        {
           Serial.print("B");
        }
        else
        {
           Serial.print("b");
        }
        if (DDRC == B11111111)
        {
           Serial.print("C");
        }
        else
        {
           Serial.print("c");
        }
        if (DDRD == B11111111)
        {
           Serial.print("D");
        }
        else
        {
           Serial.print("d");
        }
        if (DDRE == B11111111)
        {
           Serial.print("E");
        }
        else
        {
           Serial.print("e");
        }
        if (DDRF == B11111111)
        {
           Serial.print("F");
        }
        else
        {
           Serial.print("f");
        }
        if (DDRG == B11111111)
        {
           Serial.print("G");
        }
        else
        {
           Serial.print("g");
        }
        if (DDRH == B11111111)
        {
           Serial.print("H");
        }
        else
        {
           Serial.print("h");
        }
        Serial.println();
      }
    }
  }
}

void DOCRLF (String txt, int vval)
{
  Serial.print(txt);
  Serial.println(vval);
}

where REG is A - K (the registers in the ARD 2650) COMMAND can be a 2-chars command, but mostly 1-char commands.

EG:  AR:255<cr>  // AR configures DDRA to out- or in-put , depending on the parameter - (here 255 / 0xff) .

AI:0<cr>  Read port A input (actually return content of ARD2560 port A inputregister)
   
AO:<number><CR>   Send Number to port A (and return result to D-7 ).

......

All those command are valid for Reg A to Reg K.

 if (char (pport[0] == '*' ))  // '*' can be 'A' to 'K' 

the responsetime increases to appr. 2 sec's .

(sorry there's no comment !)

Thanks for Any help.

here's the Code:

#include <Esplora.h>

void setup()
{
    Serial.begin(9600);
}

void loop()
{

String chr;

  if (Serial.available() > 0)
  {
    String pport = Serial.readStringUntil(':');
    {
      String pos = Serial.readStringUntil('\n');

      if (char (pport[0] == 'A' ))        /* A */
      {
        if (pport == "AR")
        {
          DDRA = pos.toInt();
          DOCRLF("//AR+", pos.toInt());
        }
        else
        if (pport == "AI")
        {
          if (DDRA == B00000000)
          {
            Serial.print(PORTA);
            chr = "//AI";
          }
          else
          {
            chr ="//AI-";
          }
          DOCRLF(chr , pos.toInt());
        }
        else
        if (pport == "AO")
        {
          if (DDRA == B11111111)
          {
            PORTA = pos.toInt();
            chr = "//AO+";
          }
          else
          {
            chr = "//AO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "AU")
        {
          Serial.print(PORTA);
          DOCRLF("//AU+", pos.toInt());
        }
        else
        if (pport == "ABW")
        {
          PORTA = pos.toInt();
          DOCRLF("//ABW+", pos.toInt());
        }
        else
        if (pport == "ABR")
        {
          Serial.print(PORTA);
          DOCRLF("//ABR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'B' ))        /* B */
      {
        if (pport == "BR")
        {
          DDRB = pos.toInt();
          DOCRLF("//BR+", pos.toInt());
        }
        else
        if (pport == "BI")
        {
          if (DDRB == B00000000)
          {
            Serial.print(PORTB);
            chr = "//BI+";
          }
          else
          {
            chr = "//BI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "BO")
        {
          if (DDRB == B11111111)
          {
            PORTB = pos.toInt();
            chr = "//BO+";
          }
          else
          {
            chr = "//BO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "BU")
        {
          Serial.print(PORTB);
          DOCRLF("//BU+", pos.toInt());
        }
        else
        if (pport == "BBW")
        {
          PORTB = pos.toInt();
          DOCRLF("//EBW+", pos.toInt());
        }
        else
        if (pport == "BBR")
        {
          Serial.print(PORTB);
          DOCRLF("//BBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'C' ))        /* C */
      {
        if (pport == "CR")
        {
          DDRC = pos.toInt();
          DOCRLF("//CR+", pos.toInt());
        }
        else
        if (pport == "CI")
        {
          if (DDRC == B00000000)
          {
            Serial.print(PORTC);
            chr = "//CI+";
          }
          else
          {
            chr = "//CI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "CO")
        {
          if (DDRC == B11111111)
          {
            PORTC = pos.toInt();
            chr = "//CO+";
          }
          else
          {
            chr = "//CO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "CU")
        {
          Serial.print(PORTC);
          DOCRLF("//CU+", pos.toInt());
        }
        else
        if (pport == "CBW")
        {
          PORTC = pos.toInt();
          DOCRLF("//CBW+", pos.toInt());
        }
        else
        if (pport == "CBR")
        {
          Serial.print(PORTC);
          DOCRLF("//CBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'D' ))        /* D */
      {
        if (pport == "DR")
        {
          DDRD = pos.toInt();
          DOCRLF("//DR+", pos.toInt());
        }
        else
        if (pport == "DI")
        {
          if (DDRD == B00000000)
          {
            Serial.print(PORTD);
            chr = "//DI+";
          }
          else
          {
            chr = "//DI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "DO")
        {
          if (DDRD == B11111111)
          {
            PORTD = pos.toInt();
            chr = "//DO+";
          }
          else
          {
            chr = "//DO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "DU")
        {
          Serial.print(PORTD);
          DOCRLF("//DU+", pos.toInt());
        }
        else
        if (pport == "DBW")
        {
          PORTD = pos.toInt();
          DOCRLF("//DBW+", pos.toInt());
        }
        else
        if (pport == "DBR")
        {
          Serial.print(PORTE);
          Serial.println("//DBR+");
        }
      }
      else
      if (char (pport[0] == 'E' ))        /* E */
      {
        if (pport == "ER")
        {
          DDRE = pos.toInt();
          DOCRLF("//ER+", pos.toInt());
        }
        else
        if (pport == "EI")
        {
          if (DDRE == B00000000)
          {
            Serial.print(PORTE);
            chr = "//ER+";
          }
          else
          {
            chr = "//ER-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "EO")
        {
          if (DDRE == B11111111)
          {
            PORTE = pos.toInt();
            chr = "//EO+";
          }
          else
          {
            chr = "//EO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "EU")
        {
          Serial.print(PORTE);
          DOCRLF("//EU+", pos.toInt());
        }
        else
        if (pport == "EBW")
        {
          PORTE = pos.toInt();
          DOCRLF("//EBW+", pos.toInt());
        }
        else
        if (pport == "EBR")
        {
          Serial.print(PORTE);
          DOCRLF("//EBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'F' ))        /* F */
      {
        if (pport == "FR")
        {
          DDRF = pos.toInt();
          DOCRLF("//FR+", pos.toInt());
        }
        else
        if (pport == "FI")
        {
          if (DDRF == B00000000)
          {
            Serial.print(PORTF);
            chr = "//FI+";
          }
          else
          {
            chr = "//F1-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "FO")
        {
          if (DDRF == B11111111)
          {
            PORTF = pos.toInt();
            chr = "//FO+";
          }
          else
          {
            chr = "//FO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "FU")
        {
          Serial.print(PORTF);
          DOCRLF("//FU+", pos.toInt());
        }
        else
        if (pport == "FBW")
        {
          PORTF = pos.toInt();
          DOCRLF("//FBW+", pos.toInt());
        }
        else
        if (pport == "FBR")
        {
          Serial.print(PORTF);
          DOCRLF("//FBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'G' ))        /* G */
      {
        if (pport == "GR")
        {
          DDRG = pos.toInt();
          DOCRLF("//GR+", pos.toInt());
        }
        else
        if (pport == "GI")
        {
          if (DDRG == B00000000)
          {
            Serial.print(PORTG);
            chr = "//GI+";
          }
          else
          {
            chr = "//GI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "GO")
        {
          if (DDRG == B11111111)
          {
            PORTG = pos.toInt();
            chr = "//GO+";
          }
          else
          {
            chr = "//GO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "GU")
        {
          Serial.print(PORTG);
          DOCRLF("//GU+", pos.toInt());
        }
        else
        if (pport == "GBW")
        {
          PORTG = pos.toInt();
          DOCRLF("//GBW+", pos.toInt());
        }
        else
        if (pport == "GBR")
        {
          Serial.print(PORTG);
          DOCRLF("//GBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'H' ))        /* H */
      {
        if (pport == "HR")
        {
          DDRH = pos.toInt();
          DOCRLF("//HR+", pos.toInt());
        }
        else
        if (pport == "HI")
        {
          if (DDRH == B00000000)
          {
            Serial.print(PORTH);
            chr = "//HI+";
          }
          else
          {
            chr = "//HI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "HO")
        {
          if (DDRH == B11111111)
          {
            PORTH = pos.toInt();
            chr = "//HO+";
          }
          else
          {
            chr = "//HO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "HU")
        {
          Serial.print(PORTH);
          DOCRLF("//HU+", pos.toInt());
        }
        else
        if (pport == "HBW")
        {
          PORTH = pos.toInt();
          DOCRLF("//HBW+", pos.toInt());
        }
        else
        if (pport == "HBR")
        {
          Serial.print(PORTH);
          DOCRLF("//HBR+", pos.toInt());
        }
      }
      else
      if (pport == "RA")
      {
        int aport = (pos.toInt());

        if (aport > -1 && aport < 16)
        {
          Serial.println (" OK ");
        }
      }
      else
      if (pport == "KO")
      {
        Serial.print("//KO+");
        if (DDRA == B11111111)
        {
           Serial.print("A");
        }
        else
        {
           Serial.print("a");
        }
        if (DDRB == B11111111)
        {
           Serial.print("B");
        }
        else
        {
           Serial.print("b");
        }
        if (DDRC == B11111111)
        {
           Serial.print("C");
        }
        else
        {
           Serial.print("c");
        }
        if (DDRD == B11111111)
        {
           Serial.print("D");
        }
        else
        {
           Serial.print("d");
        }
        if (DDRE == B11111111)
        {
           Serial.print("E");
        }
        else
        {
           Serial.print("e");
        }
        if (DDRF == B11111111)
        {
           Serial.print("F");
        }
        else
        {
           Serial.print("f");
        }
        if (DDRG == B11111111)
        {
           Serial.print("G");
        }
        else
        {
           Serial.print("g");
        }
        if (DDRH == B11111111)
        {
           Serial.print("H");
        }
        else
        {
           Serial.print("h");
        }
        Serial.println();
      }
    }
  }
}

void DOCRLF (String txt, int vval)
{
  Serial.print(txt);
  Serial.println(vval);
}

where 
REG is A - K (the registers in the ARD 2650) 
COMMAND can be a 2-chars command, but mostly 1-char commands.

EG:  AR:255<cr>  // AR configures DDRA to out- or in-put , depending on the parameter - (here 255 / 0xff) .

AI:0<cr>  Read port A input (actually return content of ARD2560 port A input register)
   
AO:<number><CR>   Send Number to port A (and return result to D-7 ).

......

All those command are valid for Reg A to Reg K.

 if (char (pport[0] == '*' ))  // '*' can be 'A' to 'K' 

The response time increases to appr. 2 seconds.

(sorry that there are no comments!)

Here's the code:

#include <Esplora.h>

void setup()
{
    Serial.begin(9600);
}

void loop()
{

  String chr;

  if (Serial.available() > 0)
  {
    String pport = Serial.readStringUntil(':');
    {
      String pos = Serial.readStringUntil('\n');

      if (char (pport[0] == 'A' ))        /* A */
      {
        if (pport == "AR")
        {
          DDRA = pos.toInt();
          DOCRLF("//AR+", pos.toInt());
        }
        else
        if (pport == "AI")
        {
          if (DDRA == B00000000)
          {
            Serial.print(PORTA);
            chr = "//AI";
          }
          else
          {
            chr ="//AI-";
          }
          DOCRLF(chr , pos.toInt());
        }
        else
        if (pport == "AO")
        {
          if (DDRA == B11111111)
          {
            PORTA = pos.toInt();
            chr = "//AO+";
          }
          else
          {
            chr = "//AO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "AU")
        {
          Serial.print(PORTA);
          DOCRLF("//AU+", pos.toInt());
        }
        else
        if (pport == "ABW")
        {
          PORTA = pos.toInt();
          DOCRLF("//ABW+", pos.toInt());
        }
        else
        if (pport == "ABR")
        {
          Serial.print(PORTA);
          DOCRLF("//ABR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'B' ))        /* B */
      {
        if (pport == "BR")
        {
          DDRB = pos.toInt();
          DOCRLF("//BR+", pos.toInt());
        }
        else
        if (pport == "BI")
        {
          if (DDRB == B00000000)
          {
            Serial.print(PORTB);
            chr = "//BI+";
          }
          else
          {
            chr = "//BI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "BO")
        {
          if (DDRB == B11111111)
          {
            PORTB = pos.toInt();
            chr = "//BO+";
          }
          else
          {
            chr = "//BO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "BU")
        {
          Serial.print(PORTB);
          DOCRLF("//BU+", pos.toInt());
        }
        else
        if (pport == "BBW")
        {
          PORTB = pos.toInt();
          DOCRLF("//EBW+", pos.toInt());
        }
        else
        if (pport == "BBR")
        {
          Serial.print(PORTB);
          DOCRLF("//BBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'C' ))        /* C */
      {
        if (pport == "CR")
        {
          DDRC = pos.toInt();
          DOCRLF("//CR+", pos.toInt());
        }
        else
        if (pport == "CI")
        {
          if (DDRC == B00000000)
          {
            Serial.print(PORTC);
            chr = "//CI+";
          }
          else
          {
            chr = "//CI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "CO")
        {
          if (DDRC == B11111111)
          {
            PORTC = pos.toInt();
            chr = "//CO+";
          }
          else
          {
            chr = "//CO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "CU")
        {
          Serial.print(PORTC);
          DOCRLF("//CU+", pos.toInt());
        }
        else
        if (pport == "CBW")
        {
          PORTC = pos.toInt();
          DOCRLF("//CBW+", pos.toInt());
        }
        else
        if (pport == "CBR")
        {
          Serial.print(PORTC);
          DOCRLF("//CBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'D' ))        /* D */
      {
        if (pport == "DR")
        {
          DDRD = pos.toInt();
          DOCRLF("//DR+", pos.toInt());
        }
        else
        if (pport == "DI")
        {
          if (DDRD == B00000000)
          {
            Serial.print(PORTD);
            chr = "//DI+";
          }
          else
          {
            chr = "//DI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "DO")
        {
          if (DDRD == B11111111)
          {
            PORTD = pos.toInt();
            chr = "//DO+";
          }
          else
          {
            chr = "//DO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "DU")
        {
          Serial.print(PORTD);
          DOCRLF("//DU+", pos.toInt());
        }
        else
        if (pport == "DBW")
        {
          PORTD = pos.toInt();
          DOCRLF("//DBW+", pos.toInt());
        }
        else
        if (pport == "DBR")
        {
          Serial.print(PORTE);
          Serial.println("//DBR+");
        }
      }
      else
      if (char (pport[0] == 'E' ))        /* E */
      {
        if (pport == "ER")
        {
          DDRE = pos.toInt();
          DOCRLF("//ER+", pos.toInt());
        }
        else
        if (pport == "EI")
        {
          if (DDRE == B00000000)
          {
            Serial.print(PORTE);
            chr = "//ER+";
          }
          else
          {
            chr = "//ER-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "EO")
        {
          if (DDRE == B11111111)
          {
            PORTE = pos.toInt();
            chr = "//EO+";
          }
          else
          {
            chr = "//EO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "EU")
        {
          Serial.print(PORTE);
          DOCRLF("//EU+", pos.toInt());
        }
        else
        if (pport == "EBW")
        {
          PORTE = pos.toInt();
          DOCRLF("//EBW+", pos.toInt());
        }
        else
        if (pport == "EBR")
        {
          Serial.print(PORTE);
          DOCRLF("//EBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'F' ))        /* F */
      {
        if (pport == "FR")
        {
          DDRF = pos.toInt();
          DOCRLF("//FR+", pos.toInt());
        }
        else
        if (pport == "FI")
        {
          if (DDRF == B00000000)
          {
            Serial.print(PORTF);
            chr = "//FI+";
          }
          else
          {
            chr = "//F1-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "FO")
        {
          if (DDRF == B11111111)
          {
            PORTF = pos.toInt();
            chr = "//FO+";
          }
          else
          {
            chr = "//FO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "FU")
        {
          Serial.print(PORTF);
          DOCRLF("//FU+", pos.toInt());
        }
        else
        if (pport == "FBW")
        {
          PORTF = pos.toInt();
          DOCRLF("//FBW+", pos.toInt());
        }
        else
        if (pport == "FBR")
        {
          Serial.print(PORTF);
          DOCRLF("//FBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'G' ))        /* G */
      {
        if (pport == "GR")
        {
          DDRG = pos.toInt();
          DOCRLF("//GR+", pos.toInt());
        }
        else
        if (pport == "GI")
        {
          if (DDRG == B00000000)
          {
            Serial.print(PORTG);
            chr = "//GI+";
          }
          else
          {
            chr = "//GI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "GO")
        {
          if (DDRG == B11111111)
          {
            PORTG = pos.toInt();
            chr = "//GO+";
          }
          else
          {
            chr = "//GO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "GU")
        {
          Serial.print(PORTG);
          DOCRLF("//GU+", pos.toInt());
        }
        else
        if (pport == "GBW")
        {
          PORTG = pos.toInt();
          DOCRLF("//GBW+", pos.toInt());
        }
        else
        if (pport == "GBR")
        {
          Serial.print(PORTG);
          DOCRLF("//GBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'H' ))        /* H */
      {
        if (pport == "HR")
        {
          DDRH = pos.toInt();
          DOCRLF("//HR+", pos.toInt());
        }
        else
        if (pport == "HI")
        {
          if (DDRH == B00000000)
          {
            Serial.print(PORTH);
            chr = "//HI+";
          }
          else
          {
            chr = "//HI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "HO")
        {
          if (DDRH == B11111111)
          {
            PORTH = pos.toInt();
            chr = "//HO+";
          }
          else
          {
            chr = "//HO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "HU")
        {
          Serial.print(PORTH);
          DOCRLF("//HU+", pos.toInt());
        }
        else
        if (pport == "HBW")
        {
          PORTH = pos.toInt();
          DOCRLF("//HBW+", pos.toInt());
        }
        else
        if (pport == "HBR")
        {
          Serial.print(PORTH);
          DOCRLF("//HBR+", pos.toInt());
        }
      }
      else
      if (pport == "RA")
      {
        int aport = (pos.toInt());

        if (aport > -1 && aport < 16)
        {
          Serial.println (" OK ");
        }
      }
      else
      if (pport == "KO")
      {
        Serial.print("//KO+");
        if (DDRA == B11111111)
        {
           Serial.print("A");
        }
        else
        {
           Serial.print("a");
        }
        if (DDRB == B11111111)
        {
           Serial.print("B");
        }
        else
        {
           Serial.print("b");
        }
        if (DDRC == B11111111)
        {
           Serial.print("C");
        }
        else
        {
           Serial.print("c");
        }
        if (DDRD == B11111111)
        {
           Serial.print("D");
        }
        else
        {
           Serial.print("d");
        }
        if (DDRE == B11111111)
        {
           Serial.print("E");
        }
        else
        {
           Serial.print("e");
        }
        if (DDRF == B11111111)
        {
           Serial.print("F");
        }
        else
        {
           Serial.print("f");
        }
        if (DDRG == B11111111)
        {
           Serial.print("G");
        }
        else
        {
           Serial.print("g");
        }
        if (DDRH == B11111111)
        {
           Serial.print("H");
        }
        else
        {
           Serial.print("h");
        }
        Serial.println();
      }
    }
  }
}

void DOCRLF (String txt, int vval)
{
  Serial.print(txt);
  Serial.println(vval);
}

How to speed appicationapplication up (if possible)

here's the COdeCode:

How to speed appication up (if possible)

here's the COde:

How to speed application up (if possible)

here's the Code:

Source Link

How to speed appication up (if possible)

I have an ARD 2560, which I communicate with through a special written Delphi 7 program (USB handling is done in the D-7 program).

I use the command syntax:

<REG> <COMMAND) <:> <NUMBER> <CR>

where REG is A - K (the registers in the ARD 2650) COMMAND can be a 2-chars command, but mostly 1-char commands.

EG:  AR:255<cr>  // AR configures DDRA to out- or in-put , depending on the parameter - (here 255 / 0xff) .

AI:0<cr>  Read port A input (actually return content of ARD2560 port A inputregister)
   
AO:<number><CR>   Send Number to port A (and return result to D-7 ).

......

All those command are valid for Reg A to Reg K.

The response time from transmit (d7) to I ("D/7") get the answer is approx. 1 1/2 second. I have a feeling that my code is a big, big kludge (it actually works), but I would like any advice(s) to to improve code // speeding it up.

If I drop the line:

 if (char (pport[0] == '*' ))  // '*' can be 'A' to 'K' 

the responsetime increases to appr. 2 sec's .

(sorry there's no comment !)

Thanks for Any help.

here's the COde:

#include <Esplora.h>

void setup()
{
    Serial.begin(9600);
}

void loop()
{

String chr;

  if (Serial.available() > 0)
  {
    String pport = Serial.readStringUntil(':');
    {
      String pos = Serial.readStringUntil('\n');

      if (char (pport[0] == 'A' ))        /* A */
      {
        if (pport == "AR")
        {
          DDRA = pos.toInt();
          DOCRLF("//AR+", pos.toInt());
        }
        else
        if (pport == "AI")
        {
          if (DDRA == B00000000)
          {
            Serial.print(PORTA);
            chr = "//AI";
          }
          else
          {
            chr ="//AI-";
          }
          DOCRLF(chr , pos.toInt());
        }
        else
        if (pport == "AO")
        {
          if (DDRA == B11111111)
          {
            PORTA = pos.toInt();
            chr = "//AO+";
          }
          else
          {
            chr = "//AO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "AU")
        {
          Serial.print(PORTA);
          DOCRLF("//AU+", pos.toInt());
        }
        else
        if (pport == "ABW")
        {
          PORTA = pos.toInt();
          DOCRLF("//ABW+", pos.toInt());
        }
        else
        if (pport == "ABR")
        {
          Serial.print(PORTA);
          DOCRLF("//ABR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'B' ))        /* B */
      {
        if (pport == "BR")
        {
          DDRB = pos.toInt();
          DOCRLF("//BR+", pos.toInt());
        }
        else
        if (pport == "BI")
        {
          if (DDRB == B00000000)
          {
            Serial.print(PORTB);
            chr = "//BI+";
          }
          else
          {
            chr = "//BI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "BO")
        {
          if (DDRB == B11111111)
          {
            PORTB = pos.toInt();
            chr = "//BO+";
          }
          else
          {
            chr = "//BO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "BU")
        {
          Serial.print(PORTB);
          DOCRLF("//BU+", pos.toInt());
        }
        else
        if (pport == "BBW")
        {
          PORTB = pos.toInt();
          DOCRLF("//EBW+", pos.toInt());
        }
        else
        if (pport == "BBR")
        {
          Serial.print(PORTB);
          DOCRLF("//BBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'C' ))        /* C */
      {
        if (pport == "CR")
        {
          DDRC = pos.toInt();
          DOCRLF("//CR+", pos.toInt());
        }
        else
        if (pport == "CI")
        {
          if (DDRC == B00000000)
          {
            Serial.print(PORTC);
            chr = "//CI+";
          }
          else
          {
            chr = "//CI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "CO")
        {
          if (DDRC == B11111111)
          {
            PORTC = pos.toInt();
            chr = "//CO+";
          }
          else
          {
            chr = "//CO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "CU")
        {
          Serial.print(PORTC);
          DOCRLF("//CU+", pos.toInt());
        }
        else
        if (pport == "CBW")
        {
          PORTC = pos.toInt();
          DOCRLF("//CBW+", pos.toInt());
        }
        else
        if (pport == "CBR")
        {
          Serial.print(PORTC);
          DOCRLF("//CBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'D' ))        /* D */
      {
        if (pport == "DR")
        {
          DDRD = pos.toInt();
          DOCRLF("//DR+", pos.toInt());
        }
        else
        if (pport == "DI")
        {
          if (DDRD == B00000000)
          {
            Serial.print(PORTD);
            chr = "//DI+";
          }
          else
          {
            chr = "//DI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "DO")
        {
          if (DDRD == B11111111)
          {
            PORTD = pos.toInt();
            chr = "//DO+";
          }
          else
          {
            chr = "//DO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "DU")
        {
          Serial.print(PORTD);
          DOCRLF("//DU+", pos.toInt());
        }
        else
        if (pport == "DBW")
        {
          PORTD = pos.toInt();
          DOCRLF("//DBW+", pos.toInt());
        }
        else
        if (pport == "DBR")
        {
          Serial.print(PORTE);
          Serial.println("//DBR+");
        }
      }
      else
      if (char (pport[0] == 'E' ))        /* E */
      {
        if (pport == "ER")
        {
          DDRE = pos.toInt();
          DOCRLF("//ER+", pos.toInt());
        }
        else
        if (pport == "EI")
        {
          if (DDRE == B00000000)
          {
            Serial.print(PORTE);
            chr = "//ER+";
          }
          else
          {
            chr = "//ER-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "EO")
        {
          if (DDRE == B11111111)
          {
            PORTE = pos.toInt();
            chr = "//EO+";
          }
          else
          {
            chr = "//EO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "EU")
        {
          Serial.print(PORTE);
          DOCRLF("//EU+", pos.toInt());
        }
        else
        if (pport == "EBW")
        {
          PORTE = pos.toInt();
          DOCRLF("//EBW+", pos.toInt());
        }
        else
        if (pport == "EBR")
        {
          Serial.print(PORTE);
          DOCRLF("//EBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'F' ))        /* F */
      {
        if (pport == "FR")
        {
          DDRF = pos.toInt();
          DOCRLF("//FR+", pos.toInt());
        }
        else
        if (pport == "FI")
        {
          if (DDRF == B00000000)
          {
            Serial.print(PORTF);
            chr = "//FI+";
          }
          else
          {
            chr = "//F1-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "FO")
        {
          if (DDRF == B11111111)
          {
            PORTF = pos.toInt();
            chr = "//FO+";
          }
          else
          {
            chr = "//FO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "FU")
        {
          Serial.print(PORTF);
          DOCRLF("//FU+", pos.toInt());
        }
        else
        if (pport == "FBW")
        {
          PORTF = pos.toInt();
          DOCRLF("//FBW+", pos.toInt());
        }
        else
        if (pport == "FBR")
        {
          Serial.print(PORTF);
          DOCRLF("//FBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'G' ))        /* G */
      {
        if (pport == "GR")
        {
          DDRG = pos.toInt();
          DOCRLF("//GR+", pos.toInt());
        }
        else
        if (pport == "GI")
        {
          if (DDRG == B00000000)
          {
            Serial.print(PORTG);
            chr = "//GI+";
          }
          else
          {
            chr = "//GI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "GO")
        {
          if (DDRG == B11111111)
          {
            PORTG = pos.toInt();
            chr = "//GO+";
          }
          else
          {
            chr = "//GO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "GU")
        {
          Serial.print(PORTG);
          DOCRLF("//GU+", pos.toInt());
        }
        else
        if (pport == "GBW")
        {
          PORTG = pos.toInt();
          DOCRLF("//GBW+", pos.toInt());
        }
        else
        if (pport == "GBR")
        {
          Serial.print(PORTG);
          DOCRLF("//GBR+", pos.toInt());
        }
      }
      else
      if (char (pport[0] == 'H' ))        /* H */
      {
        if (pport == "HR")
        {
          DDRH = pos.toInt();
          DOCRLF("//HR+", pos.toInt());
        }
        else
        if (pport == "HI")
        {
          if (DDRH == B00000000)
          {
            Serial.print(PORTH);
            chr = "//HI+";
          }
          else
          {
            chr = "//HI-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "HO")
        {
          if (DDRH == B11111111)
          {
            PORTH = pos.toInt();
            chr = "//HO+";
          }
          else
          {
            chr = "//HO-";
          }
          DOCRLF(chr, pos.toInt());
        }
        else
        if (pport == "HU")
        {
          Serial.print(PORTH);
          DOCRLF("//HU+", pos.toInt());
        }
        else
        if (pport == "HBW")
        {
          PORTH = pos.toInt();
          DOCRLF("//HBW+", pos.toInt());
        }
        else
        if (pport == "HBR")
        {
          Serial.print(PORTH);
          DOCRLF("//HBR+", pos.toInt());
        }
      }
      else
      if (pport == "RA")
      {
        int aport = (pos.toInt());

        if (aport > -1 && aport < 16)
        {
          Serial.println (" OK ");
        }
      }
      else
      if (pport == "KO")
      {
        Serial.print("//KO+");
        if (DDRA == B11111111)
        {
           Serial.print("A");
        }
        else
        {
           Serial.print("a");
        }
        if (DDRB == B11111111)
        {
           Serial.print("B");
        }
        else
        {
           Serial.print("b");
        }
        if (DDRC == B11111111)
        {
           Serial.print("C");
        }
        else
        {
           Serial.print("c");
        }
        if (DDRD == B11111111)
        {
           Serial.print("D");
        }
        else
        {
           Serial.print("d");
        }
        if (DDRE == B11111111)
        {
           Serial.print("E");
        }
        else
        {
           Serial.print("e");
        }
        if (DDRF == B11111111)
        {
           Serial.print("F");
        }
        else
        {
           Serial.print("f");
        }
        if (DDRG == B11111111)
        {
           Serial.print("G");
        }
        else
        {
           Serial.print("g");
        }
        if (DDRH == B11111111)
        {
           Serial.print("H");
        }
        else
        {
           Serial.print("h");
        }
        Serial.println();
      }
    }
  }
}

void DOCRLF (String txt, int vval)
{
  Serial.print(txt);
  Serial.println(vval);
}