zh mg
/
Nucleo_AnalogIn
NUCLEO-F103 ADC example
main.cpp
- Committer:
- Andthen
- Date:
- 2015-12-07
- Revision:
- 0:debb5e9583ad
File content as of revision 0:debb5e9583ad:
#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; } }