Wednesday, 11 May 2016

Checking the 3Pi's batteries

This code can be loaded into Arduino to check the batteries on the 3Pi:

#include <Pololu3pi.h>
#include <PololuQTRSensors.h>
#include <OrangutanLCD.h>
#include <OrangutanAnalog.h>
OrangutanLCD lcd;
OrangutanAnalog analog;

void setup()
{
  Pololu3pi::init();
  analog.setMode(MODE_10_BIT);
}


void loop()
{
  lcd.clear();
  lcd.print("Battery ");
  lcd.gotoXY(0,1);
  lcd.print((long)(100.0 * (analog.readBatteryMillivolts_3pi() - 3000.0) / (4000.0)));
  lcd.print('%');
  delay(500);
}

No comments:

Post a Comment