this simple program is an example to let u know how the ADC can be enabled in w7500

Dependencies:   mbed

Committer:
shia
Date:
Tue May 24 09:46:00 2016 +0000
Revision:
1:6b3079b2bfcc
Parent:
0:60d6189b9b0d
current measuring

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shia 0:60d6189b9b0d 1 #include "mbed.h"
shia 0:60d6189b9b0d 2 AnalogIn Current(A0);
shia 1:6b3079b2bfcc 3 PwmOut led(D9);
shia 1:6b3079b2bfcc 4 int meas,i,max,a[10];
shia 1:6b3079b2bfcc 5 float curren=0;
shia 1:6b3079b2bfcc 6 int wattage;
shia 1:6b3079b2bfcc 7 void led_toggle(int chan, uint32_t value)
shia 1:6b3079b2bfcc 8 {
shia 1:6b3079b2bfcc 9 led = !led;
shia 1:6b3079b2bfcc 10 }
shia 0:60d6189b9b0d 11
shia 0:60d6189b9b0d 12
shia 0:60d6189b9b0d 13 int main()
shia 0:60d6189b9b0d 14 {
shia 1:6b3079b2bfcc 15 printf("\n GSAS Micro Systems \r\n");
shia 1:6b3079b2bfcc 16
shia 1:6b3079b2bfcc 17 wait(0.1f);
shia 1:6b3079b2bfcc 18 while(1){
shia 1:6b3079b2bfcc 19 meas = Current.read_u16();
shia 1:6b3079b2bfcc 20 printf("value = %d\r\n", meas);
shia 1:6b3079b2bfcc 21 curren = (meas - 2595) / 185;
shia 1:6b3079b2bfcc 22 printf("curren = %.2f\r\n", curren);
shia 1:6b3079b2bfcc 23 wattage = curren * 230;
shia 1:6b3079b2bfcc 24 printf("wattage = %d\r\n", wattage);
shia 1:6b3079b2bfcc 25 wait(0.5f) ;
shia 1:6b3079b2bfcc 26 }
shia 1:6b3079b2bfcc 27
shia 1:6b3079b2bfcc 28
shia 1:6b3079b2bfcc 29 }
shia 1:6b3079b2bfcc 30
shia 1:6b3079b2bfcc 31
shia 1:6b3079b2bfcc 32
shia 1:6b3079b2bfcc 33
shia 1:6b3079b2bfcc 34