Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:06ea14e458e3
- Child:
- 1:71b75f1d31ca
diff -r 000000000000 -r 06ea14e458e3 main.cpp
--- /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());
+ }
+}