mbed robotracer for education.
Robotracer (line follower robot ) using stepper motor.
/media/uploads/hayama/mbedrobotracer-manual-english.pdf
/media/uploads/hayama/mbedrobotracer-manual-japanese.pdf
/media/uploads/hayama/eagle-design-robotracer.zip
movie -> https://www.youtube.com/watch?v=INwun8gSds4
(for competition->) https://www.youtube.com/watch?v=l_gP2pUt4w0
Revision 1:200aad416161, committed 2013-10-02
- Comitter:
- hayama
- Date:
- Wed Oct 02 01:09:55 2013 +0000
- Parent:
- 0:da22b0b4395a
- Commit message:
- mbed robotracer for education.
;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jun 19 10:00:41 2013 +0000 +++ b/main.cpp Wed Oct 02 01:09:55 2013 +0000 @@ -152,9 +152,9 @@ } //-------------------------------------------------------------------------- -// check sensor value using serial port +// check sensors //-------------------------------------------------------------------------- -void check_sens(){ +void check_sens(){ // serial output of sensor level while (1){ pc.printf("sensC :"); pc.printf("%f\n",sensC); // pc.printf("sensSG :"); pc.printf("%f\n",sensSG); // @@ -170,6 +170,35 @@ } } +void check_sens_level(){ // leds output of sensor level + int i=0; + while (1){ + if (setSw==0) { + wait(0.01); + beep(50); + while (setSw==0); + wait(0.01); + i++; if (i>7) i=0; + } + if (i==0){leds=(int)(sens1*10); pc.printf("sens1 x 10="); pc.printf("%d\n",(int)(sens1*10)); } + if (i==1){leds=(int)(sens2*10); pc.printf("sens2 x 10="); pc.printf("%d\n",(int)(sens2*10)); } + if (i==2){leds=(int)(sens3*10); pc.printf("sens3 x 10="); pc.printf("%d\n",(int)(sens3*10)); } + if (i==3){leds=(int)(sens4*10); pc.printf("sens4 x 10="); pc.printf("%d\n",(int)(sens4*10)); } + if (i==4){leds=(int)(sens5*10); pc.printf("sens5 x 10="); pc.printf("%d\n",(int)(sens5*10)); } + if (i==5){leds=(int)(sens6*10); pc.printf("sens6 x 10="); pc.printf("%d\n",(int)(sens6*10)); } + if (i==6){leds=(int)(sensC*10); pc.printf("sensC x 10="); pc.printf("%d\n",(int)(sensC*10)); } + if (i==7){leds=(int)(sensSG*10); pc.printf("sensSG x 10="); pc.printf("%d\n",(int)(sensSG*10)); } + wait (0.1); + } +} + +void check_pos(){ // leds output of line position + while (1){ + leds=sensDout; + wait (0.1); + } +} + //-------------------------------------------------------------------------- // break and release motors //-------------------------------------------------------------------------- @@ -219,7 +248,10 @@ if (markerX==1) fmarker=0; if (markerX==0 && fmarker==0 && markerC>5) fmarker=1; if (markerX==0 && fmarker==1 && markerC==0){ - fmarker=0; beep(50); + fmarker=0; beep(50); + + + } // start/goal marker check @@ -268,7 +300,9 @@ // go selected program switch(pmode){ - case 0: check_sens(); break; // check sensors + case 0: check_sens_level(); break; // check sensors by leds + //case 0: check_sens(); break; // check sensors by serial output + //case 0: check_pos(); break; // check line position case 1: runTurn(1,1,15,500); break; // run forward case 2: runTurn(2,1,15,500); break; // turn right case 3: run(10,30); break; // trace run