i tried to look at the program for the lcd but I can’t find one for the battery extender
To measure the voltage of a battery connected to the power expander (which is what I assume you meant), connect a 3-wire extension cable from the status port to one of the analog input ports and then use some code like this.
task main()
{
float battery2Level;
char str[32];
bLCDBacklight = true;
while(1)
{
// Choose one or the other based on if you have an old or new power
// expander
// NC1, A or A1 power expander 182/volt
//battery2Level = (int)((float)SensorValue in1 ] / 182.0 );
// A2 power expander level 280/volt
battery2Level = (int)((float)SensorValue in1 ] / 280.0 );
// display on LCD, second line
sprintf( str, "battery: %.3fV", battery2Level );
displayLCDString( 1, 0, str );
// no need to run fast
wait1Msec(25);
}
}
The code reads the analog input using the SensorValue function, it then scales that number according to the numbers posted on the power expander product page and displays the result on the LCD. This code assumes you are connected to analog input 1. There are two version of power expander, you probably have a new one, but check the base for the version number.