Bertel verfolgt Linie mit kurzem Programm

Dependencies:   mbed

main.cpp

Committer:
Gsellmann_Sebastian
Date:
2016-06-06
Revision:
0:0a4b051de659

File content as of revision 0:0a4b051de659:

#include "mbed.h"
 
DigitalOut Von (P2_13);      // 12 V ON 
DigitalOut LineON (P2_5);    // Line Sensor aktivieren
DigitalIn ISO1 (P1_9);       // ISO1
DigitalIn ISO2 (P0_16);
DigitalIn ISO3 (P0_23);
DigitalIn ISO4 (P0_15);
DigitalIn ISO5 (P1_3);   
    
DigitalOut LedD1 (P1_10);      
DigitalOut LedD2 (P1_11);
DigitalOut LedD4 (P1_12);
DigitalOut LedD5 (P1_13);
DigitalOut LedD6 (P1_14);      
DigitalOut LedD7 (P1_15);
DigitalOut LedD8 (P1_16);
DigitalOut LedD9 (P1_17);
DigitalOut LedD10 (P1_18);     
DigitalOut LedD11 (P2_16);
DigitalOut LedD12 (P1_20);
DigitalOut LedD13 (P1_21);

PwmOut MotorL_EN(P1_19);
DigitalOut MotorL_FORWARD(P2_15); // Forwerts  
DigitalOut MotorL_REVERSE(P2_14); // Rückwerts 

PwmOut MotorR_EN(P2_19);
DigitalOut MotorR_FORWARD(P2_20); 
DigitalOut MotorR_REVERSE(P2_21);

int main() {
    Von=1;
    LineON=1;
    MotorL_EN=1;
    MotorR_EN=1;
    

        while (1) {
            MotorL_FORWARD = 1;
            MotorR_FORWARD = 1;
            MotorL_EN.period_ms (10);
            MotorR_EN.period_ms (10);
            MotorL_EN = 0.3f;
            MotorR_EN.pulsewidth_ms(3);
            MotorR_EN = 0.3f;
            MotorL_EN.pulsewidth_ms(3);
           

        if(ISO1 ==1){
            LedD1 =1;
            MotorL_EN = 1.0f;
            MotorR_EN.pulsewidth_ms(10);
            MotorR_EN = 1.0f;
            MotorL_EN.pulsewidth_ms(10);         

        MotorR_FORWARD=0;
        MotorL_FORWARD=0;
       
        MotorR_FORWARD=1;
        MotorL_REVERSE=1;        
        }
        
        if(ISO4 ==1){
            LedD1 =1;
            MotorL_EN = 1.0f;
            MotorR_EN.pulsewidth_ms(10);
            MotorR_EN = 1.0f;
            MotorL_EN.pulsewidth_ms(10);

        MotorR_FORWARD=0;
        MotorL_FORWARD=0;        
        MotorL_FORWARD=1;
        MotorR_REVERSE=1;
  
        }
        wait (0.01); 
        MotorL_FORWARD=0;
        MotorR_REVERSE=0; 
        MotorR_FORWARD=0;
        MotorL_REVERSE=0;        
        }}