a

Dependencies:   MotorDriver_SU mbed

Fork of tracer by Naoki Hasegawa

Committer:
12f2039e
Date:
Mon Oct 27 05:06:11 2014 +0000
Revision:
1:a9d9cd966fa4
Parent:
0:0f3034bec1f8
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
12F2041G 0:0f3034bec1f8 1 #include "mbed.h"
12F2041G 0:0f3034bec1f8 2 #include "MotorDriver_SU.h"
12F2041G 0:0f3034bec1f8 3
12F2041G 0:0f3034bec1f8 4 DigitalIn sensor1(P0_16);
12F2041G 0:0f3034bec1f8 5 DigitalIn sensor2(P0_13);
12F2041G 0:0f3034bec1f8 6 DigitalIn sensor3(P0_11);
12F2041G 0:0f3034bec1f8 7
12F2041G 0:0f3034bec1f8 8 MotorDriver_SU motor(MOTOR_DOUBLE);
12F2041G 0:0f3034bec1f8 9 MotorDriver_SU lift(MOTOR_SINGLE);
12F2041G 0:0f3034bec1f8 10
12F2041G 0:0f3034bec1f8 11 int main(){
12F2041G 0:0f3034bec1f8 12 while(1){
12F2041G 0:0f3034bec1f8 13 //patern1
12F2041G 0:0f3034bec1f8 14 if(sensor1 == 1 && sensor2 == 1 && sensor3 == 0){
12f2039e 1:a9d9cd966fa4 15 motor.Drive(0, CW, 1700); //右タイヤ
12f2039e 1:a9d9cd966fa4 16 motor.Drive(1, CW, 3200);//左タイヤ
12F2041G 0:0f3034bec1f8 17 }
12F2041G 0:0f3034bec1f8 18 //patern2
12F2041G 0:0f3034bec1f8 19 else if(sensor1 == 1 && sensor2 == 0 && sensor3 == 1){
12f2039e 1:a9d9cd966fa4 20 motor.Drive(0, CW, 3200);
12f2039e 1:a9d9cd966fa4 21 motor.Drive(1, CW, 3200);
12F2041G 0:0f3034bec1f8 22 }
12F2041G 0:0f3034bec1f8 23 //patern3
12F2041G 0:0f3034bec1f8 24 else if(sensor1 == 0 && sensor2 == 1 && sensor3 == 1){
12f2039e 1:a9d9cd966fa4 25 motor.Drive(0, CW, 3200);
12f2039e 1:a9d9cd966fa4 26 motor.Drive(1, CW, 1700);
12F2041G 0:0f3034bec1f8 27 }
12F2041G 0:0f3034bec1f8 28 //patern4
12F2041G 0:0f3034bec1f8 29 else if(sensor1 == 0 && sensor2 == 0 && sensor3 == 1){
12f2039e 1:a9d9cd966fa4 30 motor.Drive(0, CW, 1700);
12f2039e 1:a9d9cd966fa4 31 motor.Drive(1, CW, 3200);
12F2041G 0:0f3034bec1f8 32 }
12F2041G 0:0f3034bec1f8 33 //patern5
12F2041G 0:0f3034bec1f8 34 else if(sensor1 == 1 && sensor2 == 0 && sensor3 == 0){
12f2039e 1:a9d9cd966fa4 35 motor.Drive(0, CW, 3200);
12f2039e 1:a9d9cd966fa4 36 motor.Drive(1, CW, 1700);
12F2041G 0:0f3034bec1f8 37 }
12F2041G 0:0f3034bec1f8 38 //patern6
12F2041G 0:0f3034bec1f8 39 else if(sensor1 == 0 && sensor2 == 0 && sensor3 == 0){
12f2039e 1:a9d9cd966fa4 40 motor.Drive(0, CW, 3200);
12f2039e 1:a9d9cd966fa4 41 motor.Drive(1, CW, 3200);
12F2041G 0:0f3034bec1f8 42 }
12F2041G 0:0f3034bec1f8 43
12F2041G 0:0f3034bec1f8 44 //patern7
12F2041G 0:0f3034bec1f8 45 else if(sensor1 == 0 && sensor2 == 1 && sensor3 == 0){
12f2039e 1:a9d9cd966fa4 46 motor.Drive(0, CW, 3200);
12f2039e 1:a9d9cd966fa4 47 motor.Drive(1, CW, 3200);
12F2041G 0:0f3034bec1f8 48 }
12f2039e 1:a9d9cd966fa4 49 /*
12F2041G 0:0f3034bec1f8 50 //patern8 探索回転方向
12F2041G 0:0f3034bec1f8 51 //ラインの右側に出た場合 反時計回り
12F2041G 0:0f3034bec1f8 52 else if(sensor1 == 1 && sensor2 == 1 && sensor3 == 1 && hasegawa == 0){
12F2041G 0:0f3034bec1f8 53 motor.Drive(0, CW, 2048);
12F2041G 0:0f3034bec1f8 54 motor.Drive(1, CW, 1000);
12f2039e 1:a9d9cd966fa4 55 }*/
12f2039e 1:a9d9cd966fa4 56 /*//ラインの左側に出た場合 時計回り
12F2041G 0:0f3034bec1f8 57 else if(sensor1 == 1 && sensor2 == 1 && sensor3 == 1 && hasegawa == 1){
12F2041G 0:0f3034bec1f8 58 motor.Drive(0, CW, 1000);
12F2041G 0:0f3034bec1f8 59 motor.Drive(1, CW, 2048);
12f2039e 1:a9d9cd966fa4 60 }*/
12F2041G 0:0f3034bec1f8 61 else{
12f2039e 1:a9d9cd966fa4 62 motor.Drive(0, CW, 3200);
12f2039e 1:a9d9cd966fa4 63 motor.Drive(1, CW, 3200);
12F2041G 0:0f3034bec1f8 64 }
12F2041G 0:0f3034bec1f8 65
12F2041G 0:0f3034bec1f8 66 }
12F2041G 0:0f3034bec1f8 67
12F2041G 0:0f3034bec1f8 68 }