   int is_timer_on;
   float timer_value;
   unsigned long timer_start_time;
+  boolean timer_running;
   int damping;
   int prev_damping;
   boolean connections[TOTAL_NUM_OF_PINS];
 //  float past_values[TOTAL_NUM_OF_PAST_VALUES];
-  float prev_values;
+  float prev_value;
 } 
 Pin;
 

    
 //   for(int j=0; j<TOTAL_NUM_OF_PAST_VALUES; j++)
  //    g_aPins[i].past_values[j] = 0.0;
    g_aPins[i].prev_values = 0.0;
    
    g_aPins[i].is_timer_on = false;
    g_aPins[i].timer_value = 0.0;
    g_aPins[i].timer_start_time = 0;
    g_aPins[i].damping = 0;
    g_aPins[i].prev_damping = 0;
    

    fPinValSum = g_aPins[_iOutPinNum].value;
  else
    g_aPins[_iOutPinNum].value = fPinValSum;
   
  // Run timer when a timer_on command has been received and a positive edge is detected
  if( g_aPins[_iOutPinNum].is_timer_on && g_aPins[_iOutPinNum].prev_value < DIGITAL_VOLTAGE_THRESHOLD && g_aPins[_iOutPinNum].value >= DIGITAL_VOLTAGE_THRESHOLD )
    g_aPins[_iOutPinNum].timer_running = true;
  
  // IF timer_is_on && Timer_Running
    // IF timer expired
      // Set timer_is_on == false
      // 
   // ELSE
     // Set pin to HIGH (Over write the output)
 // ELSE
   // Set pin to VALUE

  // Set pin value to zero if timer expired
  if( g_aPins[_iOutPinNum].timer_running ) 
  {
    if( !((millis() - g_aPins[_iOutPinNum].timer_start_time) >= (g_aPins[_iOutPinNum].timer_value-1)*1000) ) // Not expired
    {
      fPinValSum = 1.0;
      g_aPins[_iOutPinNum].value = fPinValSum;            
    }
    else // Timer expired
    {
      g_aPins[_iOutPinNum].timer_running = false;
    }
  }
  
 /*
  // Set pin value to zero if timer expired
  if( g_aPins[_iOutPinNum].is_timer_on ) 
  {
    if( (millis() - g_aPins[_iOutPinNum].timer_start_time) >= (g_aPins[_iOutPinNum].timer_value-1)*1000 ) // Timer expired
    { 
//      Serial.println("EXPIRED...!!!");
      fPinValSum = 0.0;
      g_aPins[_iOutPinNum].value = fPinValSum;      
    }
  }
  */
  
  // Updating prev value 
  g_aPins[_iOutPinNum].prev_value = g_aPins[_iOutPinNum].value;
  
  return fPinValSum;
}
