step 5

Dependencies:   Servo mbed

main.cpp

Committer:
LanierUSNA16
Date:
2014-09-04
Revision:
0:68ec2377b85c

File content as of revision 0:68ec2377b85c:

#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