test

Dependencies:   Servo mbed

servotest.cpp

Committer:
taurin
Date:
2015-11-24
Revision:
0:788cb11e78c0

File content as of revision 0:788cb11e78c0:

#include "mbed.h"

PwmOut pwm(p21);

int main() {
    int start=510, end=2390;
    while(1){
        pwm.pulsewidth_us(start);
        wait(5);
        for(int p = start; p < end; p += 20) {
            pwm.pulsewidth_us(p);
            wait_ms(40);
        }
        pwm.pulsewidth_us(end);
        wait(5);
        for(int p = end; p >=start; p -= 20) {
             pwm.pulsewidth_us(p);
            wait_ms(40);
        }
    }
}