高石 龍河
/
Servomotor_example
use servo motor with "for"
main.cpp@0:ac013d743554, 2019-04-06 (annotated)
- 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?
User | Revision | Line number | New 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 | } |