test

Dependencies:   Servo mbed

Committer:
taurin
Date:
Tue Nov 24 05:47:07 2015 +0000
Revision:
0:788cb11e78c0
igi

Who changed what in which revision?

UserRevisionLine numberNew contents of line
taurin 0:788cb11e78c0 1 #include "mbed.h"
taurin 0:788cb11e78c0 2
taurin 0:788cb11e78c0 3 PwmOut pwm(p21);
taurin 0:788cb11e78c0 4
taurin 0:788cb11e78c0 5 int main() {
taurin 0:788cb11e78c0 6 int start=510, end=2390;
taurin 0:788cb11e78c0 7 while(1){
taurin 0:788cb11e78c0 8 pwm.pulsewidth_us(start);
taurin 0:788cb11e78c0 9 wait(5);
taurin 0:788cb11e78c0 10 for(int p = start; p < end; p += 20) {
taurin 0:788cb11e78c0 11 pwm.pulsewidth_us(p);
taurin 0:788cb11e78c0 12 wait_ms(40);
taurin 0:788cb11e78c0 13 }
taurin 0:788cb11e78c0 14 pwm.pulsewidth_us(end);
taurin 0:788cb11e78c0 15 wait(5);
taurin 0:788cb11e78c0 16 for(int p = end; p >=start; p -= 20) {
taurin 0:788cb11e78c0 17 pwm.pulsewidth_us(p);
taurin 0:788cb11e78c0 18 wait_ms(40);
taurin 0:788cb11e78c0 19 }
taurin 0:788cb11e78c0 20 }
taurin 0:788cb11e78c0 21 }