zh mg
/
Nucleo_AnalogIn
NUCLEO-F103 ADC example
Revision 0:debb5e9583ad, committed 2015-12-07
- Comitter:
- Andthen
- Date:
- Mon Dec 07 06:59:02 2015 +0000
- Commit message:
- NUCLEO-F103 ADC example
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Dec 07 06:59:02 2015 +0000 @@ -0,0 +1,22 @@ +#include "mbed.h" +AnalogIn light(A0); +DigitalOut led(LED1); + +float lvf=0; +float lvu=0; +int main() +{ + while(1) + { + lvf=(float)light; + lvu=light.read();// Converts and read the analog input value (value from 0.0 to 1.0) + lvu = lvu * 3300;// Change the value to be in the 0 to 3300 range + printf("light adc count is %f , %.0fmV \n",lvf,lvu); + wait(0.5); + if (lvu<0.7)// If the value is less than 0.7V then switch the LED on + led=1; + else + led=0; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Dec 07 06:59:02 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file