Example for pwm servomotor

Dependencies:   Servo mbed

main.cpp

Committer:
julientiron
Date:
2015-05-14
Revision:
1:86ea1eb9c60b
Parent:
0:3a3bfe92df7c

File content as of revision 1:86ea1eb9c60b:

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

int main()
{
    Servo myservo(D7);                // Create the servo object
    
    float butee_droite=0.1;
    float butee_gauche=1;
    float position=0.1;
    myservo.calibrate(0.00095, 90.0); // Calibrate the servo

    while(1) {
        while(position<butee_gauche){
            myservo.write(position);
            position = position + 0.01;
            wait_ms(100);
        }
        myservo.write(butee_droite);
        position = 0.1;
        wait_ms(500);
    }
}