yasuo hayashibara
/
robocon_motor_check
This is a check program for the Robocon Magazine.
Revision 0:8123026ac7a4, committed 2013-01-16
- Comitter:
- yasuohayashibara
- Date:
- Wed Jan 16 16:02:29 2013 +0000
- Commit message:
- This is a check program for the Robocon Magazine.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jan 16 16:02:29 2013 +0000 @@ -0,0 +1,52 @@ +#include "mbed.h" + +PwmOut motor1(p26); +PwmOut motor2(p25); +PwmOut motor3(p24); +PwmOut motor4(p23); +DigitalOut myled(LED1); + +#define PERIOD 0.00005 + +int motor(int right, int left) +{ + if (right > 0) { + motor1.pulsewidth(0.0); + motor2.pulsewidth(PERIOD * right / 200); + } else { + motor1.pulsewidth(PERIOD * (- right) / 200); + motor2.pulsewidth(0.0); + } + if (left > 0) { + motor4.pulsewidth(0.0); + motor3.pulsewidth(PERIOD * left / 200); + } else { + motor4.pulsewidth(PERIOD * (- left) / 200); + motor3.pulsewidth(0.0); + } + return 0; +} + + +int main() { + motor1.period(PERIOD); + motor1.pulsewidth(0.0); + motor2.period(PERIOD); + motor2.pulsewidth(0.0); + motor3.period(PERIOD); + motor3.pulsewidth(0.0); + motor4.period(PERIOD); + motor4.pulsewidth(0.0); + int right = 0, left = 0, del = 10; + while(1){ + myled = 1; + wait(0.2); + myled = 0; + wait(0.2); + right += del; + left += del; + if ((right >= 100)||(right <= -100)) del *= -1; + motor(right, left); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jan 16 16:02:29 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ed12d17f06 \ No newline at end of file