Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:cc4cc8826661
- Child:
- 1:482da73abda8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Aug 11 15:31:32 2011 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +#include "motordriver.h" + +Serial pc(USBTX, USBRX); // tx, rx +Motor A(p22, p6, p5, 1); // pwm, fwd, rev, can brake +Motor B(p21, p7, p8, 1); // pwm, fwd, rev, can brake + float s = 0.00; + int main() { + + pc.printf("Press 'u' to turn motor1 speed up, 'd' to turn it down\n"); + while(1) { + char c = pc.getc(); + if((c == 'u') && (s < 2.5)) { + s += 0.01; + A.speed(s); + B.speed(s); + wait(0.02); + } + if((c == 'd') && (s > 0.0)) { + s -= 0.01; + A.stop(1); + B.stop(1); + wait(0.02); + } + } + } \ No newline at end of file