 #endif
 
 /*
+ * Print volts.
+ */
+void print_mv(int mv)
+{
+    Serial.print(mv / 1000.0, 2);
+    Serial.write("mV");
+}
+
+/*
  * Print the current state of the device.
  */
 void show_state()

    // Configure pins.
    // D2 - gate output
    // A0 - gate input
    // A1 - drain input with divisor 1:3
    // A2 - +5V input with divisor 1:2
    // A3 - +15V input with divisor 1:4
    //
    pinMode(gate_output_pin, OUTPUT);


unsigned gate_output = 0;       // control voltage to the Gate pin of transistor
unsigned gate_input;            // measured voltage of the Gate pin
unsigned drain_input;           // measured voltage of the Drain pin
unsigned power5_input;          // measured voltage of +5V power source
unsigned power15_input;         // measured voltage of +15V power source

//
// Use Timer3, pins 2, 3 and 5 on Mega 2560 board.
//
static const int gate_output_pin = 2;

//
// Coefficients of resistor dividers.
//
#define DRAIN_MULT      (((33 + 10) / 10.0) * (11.33 / 11.21)) // resistors 33k and 10k
#define POWER5_MULT     (((10 + 10) / 10.0) * (5.00  / 5.08))  // resistors 10k and 10k
#define POWER15_MULT    (((33 + 10) / 10.0) * (11.39 / 11.06)) // resistors 33k and 10k

/*
 * Read a character from the serial port.
