use servo motor with "for"

Dependencies:   mbed

Committer:
Ryuga
Date:
Sat Apr 06 09:35:44 2019 +0000
Revision:
0:ac013d743554
create; ; thi is new program to use servo-motor for irst-year student

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ryuga 0:ac013d743554 1 #include "mbed.h"
Ryuga 0:ac013d743554 2
Ryuga 0:ac013d743554 3 PwmOut servo(D10);
Ryuga 0:ac013d743554 4
Ryuga 0:ac013d743554 5 int main() {
Ryuga 0:ac013d743554 6 servo.period(0.020);
Ryuga 0:ac013d743554 7 while(1) {
Ryuga 0:ac013d743554 8 for(float offset = 0.0f; offset < 0.001f; offset += 0.0001f){
Ryuga 0:ac013d743554 9 servo.pulsewidth(0.001f + offset);
Ryuga 0:ac013d743554 10 wait(0.25);
Ryuga 0:ac013d743554 11 }
Ryuga 0:ac013d743554 12 }
Ryuga 0:ac013d743554 13 }