ES305H Lanier Turchan
/
MBED_lab1_Step5
step 5
Diff: main.cpp
- Revision:
- 0:68ec2377b85c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 04 03:06:21 2014 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +#include "servo.h" +//Lab 2, step 5 + +//code given by professor +Serial pc(USBTX, USBRX); + +//establish pwm out on pin 21 +PwmOut servo1(p21); +//establish analogin on pin 15 +AnalogIn ain(p15); + +int main() + {//begin main + + //create float variable where the voltage input can be stored + float signal = 0.0; + + while (1) + {//begin while + //set computer sampling rate + pc.baud(921600); + //assign input voltage to the variable 'signal' + signal = ain; + + //set servo position to the value of 'signal' the input voltage + servo1.write(signal); + + wait(1); + + }//end while + + + }//end main \ No newline at end of file