![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Serial PC and Timer example
Revision 0:06ea14e458e3, committed 2013-09-01
- Comitter:
- Kit1
- Date:
- Sun Sep 01 10:33:17 2013 +0000
- Commit message:
- Serial PC 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 Sun Sep 01 10:33:17 2013 +0000 @@ -0,0 +1,22 @@ +/*Program 5: 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(p20); +Timer t; +float ADCdata; + +int main() { + pc.printf("ADC Data Values…\n\r"); //send an opening text message + while(1){ + t.start(); + for (int i=0;i<=9;i++) { + ADCdata=ADCdata+Ain*3.3; //sum 10 samples + } + ADCdata=ADCdata/10; //divide by 10 + wait(0.5); + pc.printf("%1.3f \n\r",ADCdata); //send the data to the terminal + t.stop(); + printf("The time taken was %f seconds\n", t.read()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Sep 01 10:33:17 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9c8f0e3462fb \ No newline at end of file