Lab 2 - Exercise 1 Analog to Digital Conversion using a variable potentiometer

Dependencies:   mbed

main.cpp

Committer:
brianconnett
Date:
2014-08-14
Revision:
1:7e6087973b59
Parent:
0:1171c72f5f28

File content as of revision 1:7e6087973b59:

//****************************************
//  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
    }
}