3Pi Projects‎ > ‎

Project 1 - Battery Charge Check

/*
   ###############################################################
   ##                                                           ##
   ##       Project 1                                           ##
   ##       Battery Charge Check                                ##
   ##       https://sites.google.com/site/3piprojects/          ##
   ##                                                           ##
   ##       Daniel J. Sullivan                                  ##
   ##       July 22, 2011                                       ##
   ##                                                           ##
   ###############################################################
*/

// This is a comment line.

/* This is a comment
      that can span multiple lines */

   
/* 
   An important point that is stressed in the 3Pi documentation is that the 3Pi
   unit can be permanently damaged if care is not taken when programming it.
   The 3Pi needs to be turned on and have sufficient charge on its batteries.
   It is up to the user to try to remember to turn the 3Pi on...
   This short code is used to write the current battery status to the LCD.
   It is helpful to add a code block like this to each of the programs that you
   write so that it is always easy to check the battery voltage. 
   A new set of batteries gives a charge reading of about 6000 mV.
   It is recommended that the batteries be changed or recharged at around 4500 mV.

  This example makes use of the Pololu C/C++/Arduino AVR Libraries. More inforamtion as to
  commands that are available can be found at: http://www.pololu.com/docs/0J18
  The standard C notation of #include is used at the top of the program to allow the commands associated 
  with the various libraries to be accessed.
*/

#include <OrangutanAnalog.h>
#include <OrangutanLCD.h>

/*
Use the Analog library to obtain battery voltage in millvolts.
Here an integer variable bat is declared and set equal to value obtained by the Analog Library
function readBatteryMillivolts
*/

int bat = OrangutanAnalog::readBatteryMillivolts();   

/*
The next block prints the battery voltage to the LCD.
  The LCD library is used to simplify the control of the LCD.
  Text is enclosed in quotes and used with print()
  The print() command is also used to write the value of a variable such as bat 
  gotoXY() sets the xy location of the cursor in the 8x2 LCD screen
          (0,0) is top left postion
          (0,1) is bottom left postion
          (7,0) is top right position
          (7,1) is bottom right position
*/

void setup(){                
  OrangutanLCD::print("Battery");
  OrangutanLCD::gotoXY(0,1);        
  OrangutanLCD::print(bat);
  OrangutanLCD::print("mV");
}

void loop()

// For a simple program the rest of the programming instructions will be put in a loop section!
  
}
   
//**************************** End of Program ***************************  

counter on tumblr
ċ
Daniel Sullivan,
Jul 26, 2011, 8:58 AM
Comments