![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
USB current meter for TG-LPC11U35-501
Diff: main.cpp
- Revision:
- 0:4286edef4003
- Child:
- 2:d6fcc8bfc037
diff -r 000000000000 -r 4286edef4003 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Jun 22 09:44:50 2014 +0000 @@ -0,0 +1,69 @@ +//********************** +// USB current meter for mbed +// +// LPC1768 flash=512KB, ADC=12bits +// LPC11U35 flash=64KB, ADC=10bits +// Nucleo ADC=12bits +// +// (C)Copyright 2014 All rights reserved by Y.Onodera +// http://einstlab.web.fc2.com +//********************** +#include "mbed.h" +#include "AQM0802.h" + +//#pragma O0 +//#pragma O1 +//#pragma O2 // default +//#pragma O3 +//#pragma Otime +//#pragma Ospace + + +#if defined(TARGET_LPC1768) +DigitalOut led1(LED1); +DigitalOut led2(LED2); +I2C i2c(p28,p27); +AnalogIn ain(p15); +#endif +// for TG-LPC11U35-501 +#if defined(TARGET_LPC11U35_501) +DigitalOut led1(P0_20); +DigitalOut led2(P0_21); +I2C i2c(P0_5,P0_4); +AnalogIn ain(P0_11); +#endif +// for Nucleo +#if defined(TARGET_NUCLEO_F401RE) +DigitalOut led1(D13); +I2C i2c(D14,D15); +AnalogIn ain(PA_0); +#endif + +AQM0802 lcd(i2c); + +int main() { + + char msg[10]; + int mA; + + sprintf(msg, "%d", SystemCoreClock ); + lcd.locate(0,0); + lcd.print(msg); + wait(1); + + sprintf(msg, "current "); + lcd.locate(0,0); + lcd.print(msg); + + while(1) { + + // current + mA = ain.read()*3.3*1000; + + sprintf(msg," %4dmA",mA); + lcd.locate(0,1); + lcd.print(msg); + wait(1); + } + +}