ECE 4180 Lab 2 Part 10

Dependencies:   Motor mbed

Fork of Motor_HelloWorld by Simon Ford

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?

UserRevisionLine numberNew 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 }