lab2 part7 just one pwn output to drive dc motor
Dependencies: mbed
main.cpp@0:ab02d26640f5, 2022-09-19 (annotated)
- Committer:
- mus3
- Date:
- Mon Sep 19 19:49:33 2022 +0000
- Revision:
- 0:ab02d26640f5
lab2 part7 just one pwm output
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mus3 | 0:ab02d26640f5 | 1 | #include "mbed.h" |
mus3 | 0:ab02d26640f5 | 2 | |
mus3 | 0:ab02d26640f5 | 3 | PwmOut control(p21); |
mus3 | 0:ab02d26640f5 | 4 | float volatile speed = 0.0f; |
mus3 | 0:ab02d26640f5 | 5 | int main() { |
mus3 | 0:ab02d26640f5 | 6 | while(1) { |
mus3 | 0:ab02d26640f5 | 7 | for (int i = 0; i < 10; i++) { |
mus3 | 0:ab02d26640f5 | 8 | speed = (float) i / 10.0; |
mus3 | 0:ab02d26640f5 | 9 | control = speed; |
mus3 | 0:ab02d26640f5 | 10 | wait(1); |
mus3 | 0:ab02d26640f5 | 11 | } |
mus3 | 0:ab02d26640f5 | 12 | } |
mus3 | 0:ab02d26640f5 | 13 | } |