![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Lab 2 - Exercise 1 Analog to Digital Conversion using a variable potentiometer
Dependencies: mbed
Revision 1:7e6087973b59, committed 2014-08-14
- Comitter:
- brianconnett
- Date:
- Thu Aug 14 15:43:31 2014 +0000
- Parent:
- 0:1171c72f5f28
- Commit message:
- ES305 Lab2 - Exercise 1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jun 17 19:14:38 2014 +0000 +++ b/main.cpp Thu Aug 14 15:43:31 2014 +0000 @@ -1,15 +1,25 @@ -//Reads input through the ADC, and transfers to PC terminal -#include "mbed.h" - -Serial pc(USBTX, USBRX); -AnalogIn Ain(p20); -float ADCdata; - -int main() { - pc.printf("ADC Data Values... \n\r"); - while (1) { - ADCdata=Ain; - pc.printf("%f \n\r",ADCdata); - wait (0.5); - } -} \ No newline at end of file +//**************************************** +// ES305 Linear Control Systems +// Lab 2 - Introduction to mbed microcontroller +// Exercise 1 - Analog to Digital Conversion +// Reads variable input through the ADC, and transfers to PC terminal +// +// Brian Connett, LCDR, USN +//**************************************** + +#include "mbed.h" //mbed header file from mbed.org includes MOST APIs required to operate LPC + +Serial pc(USBTX, USBRX); //Create a Serial port connected to USB +AnalogIn Ain(p18); //Create an AnalogIn variable connected to Pin 18 +float ADCdata; //Variable declaration to store Analog values + +int main() +{ + pc.baud(921600); //Set baud rate on Serial port to 921600 + pc.printf("ADC Data Values... \n\r"); + while (1) { + ADCdata=Ain; //Store AnalogIn value from Pin 18 into float variable + pc.printf("Analog Value: %f Voltage Value: %f \n\r",ADCdata,ADCdata*3.3); //Print to TeraTerm via Serial TX + wait (01.0); //Delay for Analysis + } +} \ No newline at end of file