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.
main.cpp
00001 /*Program 5: Reads input voltage through the ADC, and transfers to PC terminal */ 00002 #include "mbed.h" 00003 00004 Serial pc(USBTX, USBRX); //enable serial port which links to USB 00005 AnalogIn Ain(p20); 00006 Timer t; 00007 float ADCdata; 00008 00009 int main() { 00010 pc.printf("ADC Data Values…\n\r"); //send an opening text message 00011 while(1){ 00012 t.start(); 00013 for (int i=0;i<=9;i++) { 00014 ADCdata=ADCdata+Ain*3.3; //sum 10 samples 00015 } 00016 ADCdata=ADCdata/10; //divide by 10 00017 wait(0.5); 00018 pc.printf("%1.3f \n\r",ADCdata); //send the data to the terminal 00019 t.stop(); 00020 printf("The time taken was %f seconds\n", t.read()); 00021 } 00022 }
Generated on Mon Jul 18 2022 10:39:32 by
