step 1
Dependencies: mbed
Diff: Step1.cpp
- Revision:
- 0:a4358adfa505
diff -r 000000000000 -r a4358adfa505 Step1.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Step1.cpp Thu Sep 04 03:04:18 2014 +0000 @@ -0,0 +1,33 @@ + +#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 \ No newline at end of file