UNFINISHED

Dependencies:   HCSR04 SRF05 mbed

colorsensor.cpp

Committer:
Charlie_He
Date:
2018-06-08
Revision:
1:60c79e942c98

File content as of revision 1:60c79e942c98:

#include "mbed.h"
#include "gyro.h"
#include "Distance.h"

Timer ccc;

void blue()
{
    M1=-1;M2=1;//左边45度
    wait(0.4);
    M1=0;M2=0;
    change(135);
    driveit();
    ccc.start();
    while(1)
    {
        if(ccc.read()>15)
        {
            M1=1;M2=-1;//右边135度
            wait(1.25);
            M1=0;M2=0;
            change(-135);
            driveit();
            enable1();
            break;
            }
        }
    }
void red()
{   
     M1=1;M2=-1;//右边45度
    wait(0.4);
    M1=0;M2=0;
    change(45);
    driveit();
    ccc.start();
    while(1)
    {
        if(ccc.read()>15)
        {
            M1=1;M2=-1;//右边45度
            wait(0.4);
            M1=0;M2=0;
            change(-45);
            driveit();
            enable1();
            break;
            }
        }
    }
void green()
{
    change(90);
    driveit();
    ccc.start();
    while(1)
    {
        if(ccc.read()>20)
        {
            M1=1;M2=-1; //右转90
            wait(0.75);
            change(-90);
            driveit();
            enable1();
            break;
            }
        }
    }