Yasushi TAUCHI
/
m3pi_raw_line
m3pi raw sensorを使ったライントレース
Diff: main.cpp
- Revision:
- 0:793aabbce795
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 21 12:40:58 2012 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" +#include "m3pi.h" + +m3pi m3pi; +int main() { + unsigned char x[10]; + int i; + while(1) { + m3pi.putc(0x86); + for(i=0;i<10;i++){ + x[i]=m3pi.getc(); + } + m3pi.locate(0,0); + m3pi.printf(" %2x %2x",(x[3]*0x100+x[2])/8,(x[7]*0x100+x[6])/8); + m3pi.locate(0,1); + m3pi.printf("%2x %2x %2x",(x[1]*0x100+x[0])/8,(x[5]*0x100+x[4])/8,(x[9]*0x100+x[8])/8); + if(x[1]*0x100+x[0]>x[9]*0x100+x[8]){ + m3pi.left_motor(0.5); + m3pi.right_motor(0); + }else{ + m3pi.left_motor(0); + m3pi.right_motor(0.5); + } + } +}