Kevin Abraham
/
4180Lab2-10
ECE 4180 Lab 2 Part 10
Fork of Motor_HelloWorld by
main.cpp@1:b33bff7dc3ea, 2018-10-09 (annotated)
- Committer:
- abraha2d
- Date:
- Tue Oct 09 00:50:42 2018 +0000
- Revision:
- 1:b33bff7dc3ea
- Parent:
- 0:7bbc230e00d6
Save point
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 | |
abraha2d | 1:b33bff7dc3ea | 8 | int main() |
abraha2d | 1:b33bff7dc3ea | 9 | { |
abraha2d | 1:b33bff7dc3ea | 10 | while (1) { |
abraha2d | 1:b33bff7dc3ea | 11 | for (float s= -1.0; s < 1.0 ; s += 0.01) { |
abraha2d | 1:b33bff7dc3ea | 12 | m.speed(s); |
abraha2d | 1:b33bff7dc3ea | 13 | wait(0.02); |
abraha2d | 1:b33bff7dc3ea | 14 | } |
abraha2d | 1:b33bff7dc3ea | 15 | for (float s= 1.0; s > -1.0 ; s -= 0.01) { |
abraha2d | 1:b33bff7dc3ea | 16 | m.speed(s); |
abraha2d | 1:b33bff7dc3ea | 17 | wait(0.02); |
abraha2d | 1:b33bff7dc3ea | 18 | } |
simon | 0:7bbc230e00d6 | 19 | } |
simon | 0:7bbc230e00d6 | 20 | } |