       writeDAC(); break;
     case 8 :
       //read Vcc using 1.1 V on board reference
-      Serial.println(readVcc()); break;
+      Serial.println(vcc.getAverage()); break;
     case 99:
       //just dummy to cancel the current read, needed to prevent lock
       //when the PC side dropped the "w" that we sent
       break;
   }
+
+  vcc.addValue(readVcc());
+  
 }
 
 char readData() {


  //set analog reference voltage
  //analogReference(INTERNAL2V56)

  delay(300);
}

int value = 0;
int cmd = 0;

RunningAverage vcc(30);

void setup()
{
  //initialise I2C communication as Master
