cannon ball

Dependencies:   SerialDriver Servo mbed-rtos mbed

Fork of Nucleo_ServoKnob by Jose Rios

main.cpp

Committer:
jose_23991
Date:
2014-09-19
Revision:
0:3a3bfe92df7c
Child:
1:dee6f3e0db9b

File content as of revision 0:3a3bfe92df7c:

#include "mbed.h"
#include "Servo.h"

int main()
{
    Servo myservo(D3);                // Create the servo object
    AnalogIn knob(A0);                // Create the analog input object
    
    float val;
    
    myservo.calibrate(0.00095, 90.0); // Calibrate the servo
        
    while(1)
    {
        val = knob.read();            // Reads the value of the potentiometer (value between 0 and 1) 
        myservo.write(val);           // Sets the servo position according to the scaled value  (0-1)
        wait_ms(15);                  // Waits for the servo to get there 
    }
}