 const float scaleRaw2Volts = ref5V / (ratioRes * 1023.0);
 
 // *** declare variables
-int sumSamples = 0;         // sum of samples
-int cntSamples = 0;         // sample counter
-float voltage = 0.0;
 unsigned long startTime;
 unsigned long elapsedTime;
-byte cmd = 0;
+float retValue = 0.0;
+byte cmd;
 
 void setup()
 {

  // *** Determine the source voltage:
  voltage = (float)sumSamples / (float)numSamples; // Calculate avg raw value.
  voltage *= scaleRaw2Volts;      // Scale avg raw value to source voltage.

}



float sensV() // measure the voltage
{
  float voltage = 0.0;        // result
  int sumSamples = 0;         // sum of samplevalues
  int cntSamples = 0;         // sample counter

  // *** Add up the pre-defined number of samples for Sample Averaging
  for (cntSamples = 0; cntSamples <= numSamples; cntSamples++)
