     }
     else
     {
-        aJson.addItemToObject(apoPin[i],"is_input", aJson.createFalse() );
+      aJson.addItemToObject(apoPin[i],"is_input", aJson.createFalse() );
     }
 
     // Populate pin's value
     aJson.addItemToObject(apoPin[i],"value", aJson.createItem( g_aPins[i].value ) );
-    
+
     // TO DO - Add pin connections array
     aJson.addItemToObject(apoPin[i],"connections", aJson.createIntArray(iaPinConnects,0) );
-    
+    /*
+     int analogValues[6];
+     for (int i = 0; i < 6; i++) {
+     analogValues[i] = analogRead(i);
+     }
+     aJsonObject *analog = aJson.createIntArray(analogValues, 6);
+     aJson.addItemToObject(msg, "analog", analog);
+     */
+    /*
+    typedef struct Pin {
+     char label[PIN_LABEL_SIZE];
+     boolean is_analog;
+     boolean is_input;
+     float value;
+     boolean connections[TOTAL_NUM_OF_PINS];
+     } Pin;
+     
+     Pin g_aPins[TOTAL_NUM_OF_PINS];
+     */
+
     // Push to JSON structure
     sprintf(caPinNumBuffer,"%d",i);
     aJson.addItemToObject(poPins,caPinNumBuffer,apoPin[i]);
-    
-    /*
-    aJson.addItemToObject(apoPin[i],"label", aJson.createItem("None") );
-    aJson.addItemToObject(apoPin[i],"is_analog", aJson.createFalse() );
-    aJson.addItemToObject(apoPin[i],"is_input", aJson.createFalse() );
-    aJson.addItemToObject(apoPin[i],"value", aJson.createItem(0.0) );
-    aJson.addItemToObject(apoPin[i],"connections", aJson.createIntArray(iaPinConnects,0) );
-    sprintf(caPinNumBuffer,"%d",i);
-    aJson.addItemToObject(poPins,caPinNumBuffer,apoPin[i]);
-    */
-  }
-
-/*
-typedef struct Pin {
-  char label[PIN_LABEL_SIZE];
-  boolean is_analog;
-  boolean is_input;
-  float value;
-  boolean connections[TOTAL_NUM_OF_PINS];
-} Pin;
-
-Pin g_aPins[TOTAL_NUM_OF_PINS];
-*/
-
+
+  }
 
   // Create CONNECTIONS
   int iaConnections[10];

#define NUM_OF_DIGITAL_PINS 14

#define ANALOG_OUT_MAX_VALUE 255

typedef struct Pin {
  char label[PIN_LABEL_SIZE];

  // Set the HW state
  setBoardState();


  /*
  char label[25];
   boolean is_analog;
   boolean is_input;
   float value;
   int connections[20];
   } Pin;
   
   #define TOTAL_NUM_OF_PINS 20 
   Pin g_aPins[TOTAL_NUM_OF_PINS];
   */
}

void setBoardState()
{
  for(int i=0; i<TOTAL_NUM_OF_PINS; i++)
  {
    if( g_aPins[i].is_input )
    {
      pinMode(i, INPUT);
    }
    else
    {
      pinMode(i, OUTPUT);

      if( g_aPins[i].is_analog )
      {
        analogWrite(i, int(g_aPins[i].value*ANALOG_OUT_MAX_VALUE) );
      }
      else
      {
        digitalWrite(i, int(g_aPins[i].value) );
      }
    }
  }
}

void updateBoardState()
{
  for(int i=0; i<TOTAL_NUM_OF_PINS; i++)
  {
    if( g_aPins[i].is_input )
    {
      if( g_aPins[i].is_analog )
      {
        g_aPins[i].value = analogRead(i)/float(ANALOG_IN_MAX_VALUE);
      }
      else
      {
        g_aPins[i].value = digitalRead(i);
      }
    }
    else
    {
      if( g_aPins[i].is_analog )
      {
        analogWrite(i, int(g_aPins[i].value*ANALOG_OUT_MAX_VALUE) );
      }
      else
      {
        digitalWrite(i, int(g_aPins[i].value) );
      }
    }
  }
}


// Get the board state and return a JSON object
aJsonObject* getJsonBoardState()
{
  //aJsonObject *msg = aJson.parse("{\"status\":OK,\"pins\":{\"13\":{\"label\":\"LED ON 13\",\"is_analog\":\"false\",\"is_input\":\"false\",\"value\":\"0.0\",\"connections\":[]}},\"connections\":[]}\"");

  aJsonObject* poJsonBoardState = aJson.createObject();

  // Creating status JSON object
  aJsonObject* poStatus = aJson.createObject();

