Example application for MAX1704X LiPo battery fuel gauge

Dependencies:   MAX1704X

main.cpp

Committer:
maclobdell
Date:
2017-10-09
Revision:
0:f63374514537

File content as of revision 0:f63374514537:

#include "mbed.h"
#include "MAX1704X.h"

//Create an MAX1704X object at the default address (ADDRESS_0)
MAX1704X battery_level(D14, D15);  //sda, scl

int main()
{
    //Try to open the MAX1704X
    if (battery_level.open()) {
        printf("Device detected!\n");

        while (1) {
            //Print the current battery level
            printf("battery = %d\n", battery_level.read_percent());

            //Sleep for 1 seconds
            wait(1);
        }
    } else {
        error("Device not detected!\n");
    }
}