First program to demonstrate a working robot. crude and ugly, basicly a smoke test.
Dependencies: mbed Motordriver Servo GP2xx
Revision 0:0bc8408a55f8, committed 2010-12-01
- Comitter:
- littlexc
- Date:
- Wed Dec 01 21:20:04 2010 +0000
- Commit message:
- purely a test software to show that the system can do something
Changed in this revision
diff -r 000000000000 -r 0bc8408a55f8 GP2xx.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GP2xx.lib Wed Dec 01 21:20:04 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/littlexc/code/GP2xx/#e3ea40a41d27
diff -r 000000000000 -r 0bc8408a55f8 Motordriver.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motordriver.lib Wed Dec 01 21:20:04 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/littlexc/code/Motordriver/#3110b9209d3c
diff -r 000000000000 -r 0bc8408a55f8 Servo.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Wed Dec 01 21:20:04 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 0bc8408a55f8 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Dec 01 21:20:04 2010 +0000 @@ -0,0 +1,99 @@ +#include <mbed.h> +#include <motordriver.h> +#include <Servo.h> +#include <GP2xx.h> +//pc interface +Serial pc(USBTX, USBRX); // tx, rx +//servos +Servo LeftServo(p24); +Servo RightServo(p23); +//motors, left and right side +Motor leftM(p22, p6, p5, 1); // pwm, fwd, rev, can break +Motor rightM(p21, p7, p8, 1); // pwm, fwd, rev, can break +//range finders, left and right side, and left and right front +IRRangeFinder LS(p18,1); +IRRangeFinder LF(p17,1); +IRRangeFinder RF(p16,1); +IRRangeFinder RS(p15,1); +//debug leds. +DigitalOut led1 (LED1); +DigitalOut led2 (LED2); +DigitalOut led3 (LED3); +DigitalOut led4 (LED4); +DigitalOut ledleft (p14); +DigitalOut ledright (p13); +DigitalOut ledfront (p12); + +int quickfirstprog() {//initalisation + led1 = led2 = led3 = led4 = 1;//lights + leftM.speed(0.5); + rightM.speed(-0.5);//shows that it works. + wait(1); + while (1) {//infinate loop to drive around + switch ( RS.read() ) {//ugly horrible switch statements that implement a crude attempt at object avoidance + case 4://really this exists to prove that the system drives, and the IR rangefinders have some sane values. + leftM.speed(-0.9); + break; + case 5: + leftM.speed(-0.8); + break; + case 7: + leftM.speed(-0.7); + break; + case 8: + leftM.speed(-0.6); + break; + case 10: + leftM.speed(-0.4); + break; + case 12: + leftM.speed(-0.2); + break; + case 14: + leftM.speed(0.0); + break; + case 20: + leftM.speed(0.4); + break; + case 25: + leftM.speed(0.6); + break; + case 30: + leftM.speed(0.8); + break; + } + switch ( LF.read() ) { + case 4: + rightM.speed(-1); + break; + case 5: + rightM.speed(-0.9); + break; + case 7: + rightM.speed(-0.8); + break; + case 8: + rightM.speed(-0.7); + break; + case 10: + rightM.speed(-0.6); + break; + case 12: + rightM.speed(-0.4); + break; + case 14: + rightM.speed(0.0); + break; + case 20: + rightM.speed(0.4); + break; + case 25: + rightM.speed(0.6); + break; + case 30: + rightM.speed(0.8); + break; + } + wait(0.1); + }//end of infinate loop to drive around +} \ No newline at end of file
diff -r 000000000000 -r 0bc8408a55f8 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Dec 01 21:20:04 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e