step 1

Dependencies:   mbed

Step1.cpp

Committer:
LanierUSNA16
Date:
2014-09-04
Revision:
0:a4358adfa505

File content as of revision 0:a4358adfa505:


#include "mbed.h"
//Lab 2, part 1

//code given by professor
Serial pc(USBTX, USBRX);
//establish analog input on pin 15 called ain
AnalogIn ain(p15); 

int main()
    {//begin main
      //assign float variables where we can store the input voltage and its digital value  
    float voltage = 0.0; 
    //digital voltage
    float signal = 0.0;
    //analog voltage
    while (1)
    {
        //set the computer sampling rate to max possible
    pc.baud(921600);
    //scale the analog input voltage to get the digital
    voltage = ain*3.33; 
    //assign the analog to the variable signal
    signal = ain; 
    
    printf("Voltage = %.3f   Signal = %f\n", voltage, signal);
    
    wait(1);
    
    
    }//end while
    
    }//end main