embedded mulmeter
Dependencies: INA219 SDFileSystem mbed
Fork of INA219-HelloWorld by
Revision 1:a39067e83bd8, committed 2016-03-30
- Comitter:
- MLev
- Date:
- Wed Mar 30 15:14:33 2016 +0000
- Parent:
- 0:363487963041
- Commit message:
- hop !
Changed in this revision
SDFileSystem.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 363487963041 -r a39067e83bd8 SDFileSystem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Wed Mar 30 15:14:33 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/SDFileSystem/#7b35d1709458
diff -r 363487963041 -r a39067e83bd8 main.cpp --- a/main.cpp Thu Aug 28 10:39:58 2014 +0000 +++ b/main.cpp Wed Mar 30 15:14:33 2016 +0000 @@ -1,30 +1,57 @@ #include "mbed.h" #include "INA219.hpp" +#include "SDFileSystem.h" 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); +INA219 ina219(D14, D15, 0x40, 400000, RES_10BITS); -Ticker measure; -float refresh_rate = 1000; +DigitalOut led_red(LED_RED); +DigitalOut led_green(LED_GREEN); +DigitalIn sw3(SW3); + +int a; -void show_current() +int check_sw3(void) { - float current_ma = ina219.read_current_mA(); - pc.printf("%f\r\n", current_ma); + if (sw3 == 0) { + printf("SW2 button pressed. \n"); + a = 1; + }else a =0; - led1 = !led1; + return a; } int main(void) { - pc.baud(921600); + pc.baud(9600); + //printf("\n 1234234 hello\n"); + //float refresh_interval = 1/refresh_rate; + + printf("hello this is the current and voltage of our circuit\r\n\n"); + float volt; + float current_ma; + + if((fp1 != NULL) && (fp2 != NULL)) + { + led_green = 0; // + led_red = 1; + a = 0; + while(a == 0){ + volt= ina219.read_bus_voltage(); + current_ma = ina219.read_current_mA(); + + printf("\r volt :%f\n", volt); + printf("\r courant : %f\n\n", current_ma); + + wait(5); + a = check_sw3(); + } + } - float refresh_interval = 1/refresh_rate; - measure.attach(&show_current, refresh_interval); - - while (1) { - } + led_red = 0; // on + led_green = 1; // off + + } \ No newline at end of file