   Robot.line(127, 1, 127, 5);
 }
 
-void batteryUpdate()
+int batteryUpdate()
 {
+    
   Robot.noStroke();
   value_old = value;
-  value = readVcc();
-  int level = map(value, 4400, 5000, 1, 11);
+  value = batteryVcc();
+ 
+  if (value == value_old) {
+    // No need to redraw the same value to the screen.
+    return value;
+  }
+
+  int level = map(constrain(value, 4400, 5000), 4400, 5000, 1, 11);
   if (level < 3) {
     Robot.fill(255,0,0); 
   } else if (level < 7) {
-    Robot.fill(0,0,255); 
+    Robot.fill(255,255,0); 
   } else {
     Robot.fill(0,255,0); 
   }

  
  Robot.textSize(2);
  Robot.text("mV", 92, 58); 
}

long readVcc() 
{
  // Read 1.1V reference against AVcc
  // set the reference to Vcc and the measurement to the internal 1.1V reference
  #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

void loop()
{
  batteryUpdate();
  delay(100);
}

void batteryDraw()
