embedded mulmeter
Dependencies: INA219 SDFileSystem mbed
Fork of INA219-HelloWorld by
main.cpp
- Committer:
- MLev
- Date:
- 2016-03-30
- Revision:
- 1:a39067e83bd8
- Parent:
- 0:363487963041
File content as of revision 1:a39067e83bd8:
#include "mbed.h" #include "INA219.hpp" #include "SDFileSystem.h" Serial pc(USBTX, USBRX); // Get this to work with the INA219 Breakout from Adafruit INA219 ina219(D14, D15, 0x40, 400000, RES_10BITS); DigitalOut led_red(LED_RED); DigitalOut led_green(LED_GREEN); DigitalIn sw3(SW3); int a; int check_sw3(void) { if (sw3 == 0) { printf("SW2 button pressed. \n"); a = 1; }else a =0; return a; } int main(void) { 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(); } } led_red = 0; // on led_green = 1; // off }