Farbod Jam / Mbed 2 deprecated GOLOOMOTOR

Dependencies:   mbed

Committer:
farbodjam
Date:
Thu Aug 11 15:31:32 2011 +0000
Revision:
0:cc4cc8826661
Child:
1:482da73abda8
intrface motor with hyper terminal use L293d WITH 2 DC MOTOR DRIVE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
farbodjam 0:cc4cc8826661 1 #include "mbed.h"
farbodjam 0:cc4cc8826661 2 #include "motordriver.h"
farbodjam 0:cc4cc8826661 3
farbodjam 0:cc4cc8826661 4 Serial pc(USBTX, USBRX); // tx, rx
farbodjam 0:cc4cc8826661 5 Motor A(p22, p6, p5, 1); // pwm, fwd, rev, can brake
farbodjam 0:cc4cc8826661 6 Motor B(p21, p7, p8, 1); // pwm, fwd, rev, can brake
farbodjam 0:cc4cc8826661 7 float s = 0.00;
farbodjam 0:cc4cc8826661 8 int main() {
farbodjam 0:cc4cc8826661 9
farbodjam 0:cc4cc8826661 10 pc.printf("Press 'u' to turn motor1 speed up, 'd' to turn it down\n");
farbodjam 0:cc4cc8826661 11 while(1) {
farbodjam 0:cc4cc8826661 12 char c = pc.getc();
farbodjam 0:cc4cc8826661 13 if((c == 'u') && (s < 2.5)) {
farbodjam 0:cc4cc8826661 14 s += 0.01;
farbodjam 0:cc4cc8826661 15 A.speed(s);
farbodjam 0:cc4cc8826661 16 B.speed(s);
farbodjam 0:cc4cc8826661 17 wait(0.02);
farbodjam 0:cc4cc8826661 18 }
farbodjam 0:cc4cc8826661 19 if((c == 'd') && (s > 0.0)) {
farbodjam 0:cc4cc8826661 20 s -= 0.01;
farbodjam 0:cc4cc8826661 21 A.stop(1);
farbodjam 0:cc4cc8826661 22 B.stop(1);
farbodjam 0:cc4cc8826661 23 wait(0.02);
farbodjam 0:cc4cc8826661 24 }
farbodjam 0:cc4cc8826661 25 }
farbodjam 0:cc4cc8826661 26 }