[m3pi] Battery Display and Sharp Distance Sensor

24 Nov 2011

SOLVED

Heya! I've started working today with the awesome mbed on my m3pi robot. Two big questions for a newb like me.

1) I'm trying to display my current voltage (as in the normal 3pi codes.) I've tried doing so with

Battery

#include "mbed.h"
#include "m3pi.h"

m3pi m3pi;
float bat;
char buffer [4];

int main() {

    m3pi.locate(0,1); 
    while(1)
    {
        bat=m3pi.battery();
        bat=bat*1000;
        sprintf (buffer, "%f", bat);
        m3pi.cls();
        m3pi.printf(buffer);
        wait(0.5);        
    }
}

- I've rewritten the code and now it works. --

2)Right, if you want to connect an AnalogIn you can do so straight to the mbed. http://mbed.org/handbook/AnalogIn this is very helpful.

09 May 2012
16 Jan 2013

Is this your final version that WORKED? (in your post) I can't print the battery voltage on my 3pi using it or anything I can dream up! Bo

I couldn't get cut/paste to work to put it here.