4180 LabTeam - Spring '18
/
Motor_HelloWorld
4180 H-Bridge motor
Fork of Motor_HelloWorld by
main.cpp@1:159946ba2b28, 2018-03-07 (annotated)
- Committer:
- Nydrel
- Date:
- Wed Mar 07 03:04:22 2018 +0000
- Revision:
- 1:159946ba2b28
- Parent:
- 0:7bbc230e00d6
4180 H-Bridge motor control
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 | |
Nydrel | 1:159946ba2b28 | 6 | Motor m(p23, p12, p11); // pwm, fwd, rev |
Nydrel | 1:159946ba2b28 | 7 | AnalogIn pot(p15); |
simon | 0:7bbc230e00d6 | 8 | |
simon | 0:7bbc230e00d6 | 9 | int main() { |
Nydrel | 1:159946ba2b28 | 10 | float s; |
Nydrel | 1:159946ba2b28 | 11 | while(1){ |
Nydrel | 1:159946ba2b28 | 12 | s = (pot*2)-1; |
Nydrel | 1:159946ba2b28 | 13 | m.speed(s); |
Nydrel | 1:159946ba2b28 | 14 | wait(0.01); |
simon | 0:7bbc230e00d6 | 15 | } |
simon | 0:7bbc230e00d6 | 16 | } |