ECE 4180
/
LAB2-Part10-Hbridge
Hbridge Motor Code
Revision 1:4f9e3d0c8d6e, committed 2020-03-03
- Comitter:
- jlee3588
- Date:
- Tue Mar 03 01:04:13 2020 +0000
- Parent:
- 0:7bbc230e00d6
- Commit message:
- abc
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7bbc230e00d6 -r 4f9e3d0c8d6e main.cpp --- a/main.cpp Tue Nov 23 16:19:19 2010 +0000 +++ b/main.cpp Tue Mar 03 01:04:13 2020 +0000 @@ -3,11 +3,19 @@ #include "mbed.h" #include "Motor.h" -Motor m(p23, p6, p5); // pwm, fwd, rev +Motor m(p22, p13, p14); // pwm, fwd, rev +AnalogIn pot(p20); int main() { - for (float s= -1.0; s < 1.0 ; s += 0.01) { - m.speed(s); - wait(0.02); + //for (float s= -1.0; s < 1.0 ; s += 0.1) { +// m.speed(s); +// wait(1); +// } + float control; + while(1){ + control = 2*(1-pot)-1; + m.speed(control); + wait(0.3); } + }