LAB2
/
lab2_part5
lab2 part5
Diff: main.cpp
- Revision:
- 0:27be254c7ddc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Sep 03 19:49:24 2014 +0000 @@ -0,0 +1,20 @@ +#include "mbed.h" +#include "Servo.h" +Serial pc(USBTX, USBRX); + +int main() { + + pc.baud(921600); //set the baud rate to 921600 + float x,y; //creates variables + AnalogIn an(p15); // sets pin15 as an analogin + PwmOut sm(p21); // sets pin21 as a PwmOut + + while(1) + { + x=an.read(); // read in the value off an + y=x*3.3; // convert to associated voltage + printf("The analog data value is %f, and the associated voltage is %f\n",x, y); + sm=x; //set the PwmOut, sm, to the value read off of an. + wait(.1); + } + } \ No newline at end of file