Components
/
INA219-HelloWorld
Hello world for the INA219 current sensing breakout form Adafruit
Revision 0:363487963041, committed 2014-08-28
- Comitter:
- melse
- Date:
- Thu Aug 28 10:39:58 2014 +0000
- Commit message:
- Initial Commit
Changed in this revision
diff -r 000000000000 -r 363487963041 INA219.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/INA219.lib Thu Aug 28 10:39:58 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/components/code/INA219/#eee9c8ba72ff
diff -r 000000000000 -r 363487963041 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Aug 28 10:39:58 2014 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" +#include "INA219.hpp" + +Serial pc(USBTX, USBRX); +DigitalOut led1(p25); + +// Get this to work with the INA219 Breakout from Adafruit +INA219 ina219(p28, p27, 0x40, 400000, RES_10BITS); + +Ticker measure; +float refresh_rate = 1000; + +void show_current() +{ + float current_ma = ina219.read_current_mA(); + pc.printf("%f\r\n", current_ma); + + led1 = !led1; +} + +int main(void) +{ + pc.baud(921600); + + float refresh_interval = 1/refresh_rate; + measure.attach(&show_current, refresh_interval); + + while (1) { + } +} \ No newline at end of file
diff -r 000000000000 -r 363487963041 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Aug 28 10:39:58 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file