part1 in progress
Dependencies: Motordriver Servo mbed
Revision 0:306c3cd7fc05, committed 2015-03-24
- Comitter:
- yifeng021
- Date:
- Tue Mar 24 02:38:53 2015 +0000
- Commit message:
- part1 in progress
Changed in this revision
diff -r 000000000000 -r 306c3cd7fc05 Motordriver.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motordriver.lib Tue Mar 24 02:38:53 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/littlexc/code/Motordriver/#3110b9209d3c
diff -r 000000000000 -r 306c3cd7fc05 Servo.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Tue Mar 24 02:38:53 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 306c3cd7fc05 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 24 02:38:53 2015 +0000 @@ -0,0 +1,56 @@ +// test code, this demonstrates working motor drivers. +// full reverse to full stop, dynamicaly brake and switch off. +#include "mbed.h" +#include "motordriver.h" +#include "Servo.h" +DigitalOut myled(LED1); +//PwmOut servo1(p23); +Motor A(p22, p11, p12, 1); // pwm, fwd, rev, can brake +//Motor B(p21, p7, p8, 1); // pwm, fwd, rev, can brake +Servo s1(p23); + +int main() { + //PWMout1.period(1.0/50.0); + int i = 0; + bool up = true; + s1.calibrate(0.02, 180); //myServo.calibrate(x,y) + //x sets servo rotate speed + //y sets full range of rotation + //in reality, even though we set range to 180deg, the actual range + //the servo reaches is slightly less than 180deg + while(1) { + s1 = i/100.0; + wait(0.01); + //Sensor moves from one extreme position to the other + if (up) { + i++; + if (i == 100) {up = false;} + } + //Sensor moves from one extreme position to the other + else { + i--; + if (i == 0) {up = true;} + } + A.speed(-0.8); + wait(0.01); + } + +/* +while (1) { + + //for (float s= -1.0; s < 0.0 ; s += 0.01) { + //A.speed(s); + //B.speed(s); + //wait(0.02); + //} + + while (1) { + A.speed(-0.8); + wait(0.01); + } + A.stop(0.5); + wait(1); + A.coast(); +} +*/ +}
diff -r 000000000000 -r 306c3cd7fc05 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Mar 24 02:38:53 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0 \ No newline at end of file