ECE4180
/
4180lab2_part7_Motor
motor
Fork of Motor_HelloWorld by
main.cpp@0:7bbc230e00d6, 2010-11-23 (annotated)
- Committer:
- simon
- Date:
- Tue Nov 23 16:19:19 2010 +0000
- Revision:
- 0:7bbc230e00d6
- Child:
- 1:1997f5ee08bc
Use Motor library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:7bbc230e00d6 | 1 | // Sweep the motor speed from full-speed reverse (-1.0) to full speed forwards (1.0) |
simon | 0:7bbc230e00d6 | 2 | |
simon | 0:7bbc230e00d6 | 3 | #include "mbed.h" |
simon | 0:7bbc230e00d6 | 4 | #include "Motor.h" |
simon | 0:7bbc230e00d6 | 5 | |
simon | 0:7bbc230e00d6 | 6 | Motor m(p23, p6, p5); // pwm, fwd, rev |
simon | 0:7bbc230e00d6 | 7 | |
simon | 0:7bbc230e00d6 | 8 | int main() { |
simon | 0:7bbc230e00d6 | 9 | for (float s= -1.0; s < 1.0 ; s += 0.01) { |
simon | 0:7bbc230e00d6 | 10 | m.speed(s); |
simon | 0:7bbc230e00d6 | 11 | wait(0.02); |
simon | 0:7bbc230e00d6 | 12 | } |
simon | 0:7bbc230e00d6 | 13 | } |