Testing Analog from LDR
Dependencies: mbed
Fork of PE_05-04_LoggingData by
main.cpp
- Committer:
- Richard37
- Date:
- 2014-11-18
- Revision:
- 1:a8d819e5c10d
- Parent:
- 0:ec4e2bc1996f
File content as of revision 1:a8d819e5c10d:
/*Program Example 5.4: Reads input voltage through the ADC, and transfers to PC terminal */ #include "mbed.h" Serial pc(USBTX, USBRX); //enable serial port which links to USB AnalogIn Ain(A0); unsigned int ADCdata; float LightVolts; int main() { pc.printf("ADC Data Values...\n\r"); //send an opening text message while(1){ ADCdata=Ain.read_u16(); //LightVolts=ADCdata*3.3; wait(0.5); // pc.printf("%1.3f \n\r",LightVolts); //send the data to the terminal pc.printf("%x \n\r",ADCdata); //send the data to the terminal } }