SHIVA T
/
ADC
this simple program is an example to let u know how the ADC can be enabled in w7500
Revision 1:6b3079b2bfcc, committed 2016-05-24
- Comitter:
- shia
- Date:
- Tue May 24 09:46:00 2016 +0000
- Parent:
- 0:60d6189b9b0d
- Commit message:
- current measuring
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 60d6189b9b0d -r 6b3079b2bfcc main.cpp --- a/main.cpp Wed Dec 23 10:27:26 2015 +0000 +++ b/main.cpp Tue May 24 09:46:00 2016 +0000 @@ -1,22 +1,34 @@ #include "mbed.h" AnalogIn Current(A0); -int meas; +PwmOut led(D9); +int meas,i,max,a[10]; +float curren=0; +int wattage; +void led_toggle(int chan, uint32_t value) +{ + led = !led; +} int main() { - printf("\n GSAS Micro Systems \r\n"); - - wait(0.1f); - - while(1) { - meas = Current.read_u16(); - - printf("value = %d\r\n",meas); - wait(0.1f); - } - - - } - - \ No newline at end of file + printf("\n GSAS Micro Systems \r\n"); + + wait(0.1f); + while(1){ + meas = Current.read_u16(); + printf("value = %d\r\n", meas); + curren = (meas - 2595) / 185; + printf("curren = %.2f\r\n", curren); + wattage = curren * 230; + printf("wattage = %d\r\n", wattage); + wait(0.5f) ; + } + + + } + + + + +