Linesensor

Dependencies:   mbed

Fork of BERTL14_LINESENSOR by Wolfgang Raimann

main.cpp

Committer:
DomiSukic
Date:
2015-06-17
Revision:
1:9e097feb3b19
Parent:
0:acfdc7c80165

File content as of revision 1:9e097feb3b19:


#include "mbed.h"

DigitalOut myled(LED1);

DigitalOut MotorL_EN(p34);
DigitalOut MotorL_FORWARD(P1_0);
DigitalOut MotorL_REVERSE(P1_1);
 
DigitalOut MotorR_EN(p36);
DigitalOut MotorR_FORWARD(P1_3);
DigitalOut MotorR_REVERSE(P1_4);

BusIn linesensor(p18, p16, p19, p17);

BusOut leds(LED1, LED2, LED3, LED4);


int main() 
{       
while (1)
{
        leds = linesensor;
        
        while (linesensor == 0x0)
        {
        MotorL_FORWARD = 0;    
        MotorR_REVERSE = 0;
        MotorL_REVERSE = 1;
        MotorR_FORWARD = 1;
        MotorL_EN = 1;
        MotorR_EN = 1;    
        
        leds = linesensor;     
        }
        
        while (linesensor == 0xC || linesensor == 0x8)
        {
        MotorL_FORWARD = 0;    
        MotorR_FORWARD = 0;
        MotorL_REVERSE = 1;
        MotorR_REVERSE = 1;
        MotorL_EN = 1;
        MotorR_EN = 1; 
        
        wait (0.3);
        
        leds = linesensor;
        }  
        
        while (linesensor == 0x3 || linesensor == 0x1)
        {
        MotorL_FORWARD = 1;    
        MotorR_FORWARD = 1;
        MotorL_REVERSE = 0;
        MotorR_REVERSE = 0;
        MotorL_EN = 1;
        MotorR_EN = 1; 
        
        wait (0.3);
        
        leds = linesensor;
        }  
        
         while (linesensor == 0x6)
        {
        MotorL_FORWARD = 1;    
        MotorR_REVERSE = 1;
        MotorL_REVERSE = 0;
        MotorR_FORWARD = 0;
        MotorL_EN = 1;
        MotorR_EN = 1;    
        
        leds = linesensor;     
        }
                      
}
}