![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
transmitter code
Fork of SerialPC by
Diff: main.cpp
- Revision:
- 0:06ea14e458e3
- Child:
- 1:71d38917bdce
--- /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()); + } +}