Bertel fährt mit Tastern

Dependencies:   mbed

main.cpp

Committer:
Gsellmann_Sebastian
Date:
2016-06-06
Revision:
0:6732508afb31

File content as of revision 0:6732508afb31:

#include "mbed.h"

DigitalOut Von (P2_13);           // Motor Spannung ab BERTL15 nötig !
DigitalOut MotorL_EN(P1_19);      // Enable        OB DIE LINKS ODER RECHTS IST NOCH NICHT KLAR !    
DigitalOut MotorL_FORWARD(P2_14); // Forwerts  
DigitalOut MotorL_REVERSE(P2_15); // Rückwerts  

DigitalOut MotorR_EN(P2_19);      //Die Leitung führt zum Pin PO_21 am Prozessor
DigitalOut MotorR_FORWARD(P2_21); //Die Leitung führt zum Pin P1_3 am Prozessor
DigitalOut MotorR_REVERSE(P2_20);

DigitalIn TA1 (P1_23);      
DigitalIn TA2 (P1_24);
DigitalIn TA3 (P1_25);
DigitalIn TA4 (P1_26);
DigitalIn TA5 (P1_27);      
DigitalIn TA6 (P1_28);
DigitalIn TA7 (P1_30);
DigitalIn TA8 (P1_31);





DigitalOut LedD6 (P1_14);      
DigitalOut LedD7 (P1_15);
DigitalOut LedD8 (P1_16);
DigitalOut LedD9 (P1_17);


int main() {                     // Start Hauptprogramm
    Von=1;                       // Motor Spannung EIN
    MotorR_EN=MotorL_EN=1; 
    
    while(1) {
 
    if (TA8==1){                //ggf
    MotorL_REVERSE=1;
    MotorR_REVERSE=1;
    LedD7 = 1;
    LedD9 = 1;
        
    }else  {
    {
           
    LedD7 = 0;
    LedD9 = 0;
    MotorL_REVERSE=0;
    MotorR_REVERSE=0;
    MotorR_FORWARD=1;
    MotorL_FORWARD=1;
    wait(0.5);
    MotorL_FORWARD=0;
    wait(0.5);
    MotorR_FORWARD=0;
    MotorL_REVERSE=1;
    MotorR_REVERSE=1;  
    }} 
    
    if (TA3==1){                //ggf
    MotorL_REVERSE=1;
    MotorR_REVERSE=1;
    LedD7 = 1;
    LedD9 = 1;
      
    }else  {
    {
           
    LedD7 = 0;
    LedD9 = 0;
    MotorL_REVERSE=0;
    MotorR_REVERSE=0;
    MotorR_FORWARD=1;
    MotorL_FORWARD=1;
    wait(0.5);
    MotorL_FORWARD=0;
    wait(0.5);
    MotorR_FORWARD=0;
    MotorL_REVERSE=1;
    MotorR_REVERSE=1;  
    }} 
    
    if (TA7==1){                //ggf
    MotorL_REVERSE=1;
    MotorR_REVERSE=1;
    LedD7 = 1;
    LedD9 = 1;
       
    }else  {
    {
            
    LedD7 = 0;
    LedD9 = 0;
    MotorL_REVERSE=0;
    MotorR_REVERSE=0;
    MotorR_FORWARD=1;
    MotorL_FORWARD=1;
    wait(0.5);
    MotorR_FORWARD=0;
    wait(0.5);
    MotorL_FORWARD=0;
    MotorL_REVERSE=1;
    MotorR_REVERSE=1;  
    }} 
    
     if (TA2==1){                //ggf
    MotorL_REVERSE=1;
    MotorR_REVERSE=1;
    LedD7 = 1;
    LedD9 = 1;
        
    }else  {
    {
            
    LedD7 = 0;
    LedD9 = 0;
    MotorL_REVERSE=0;
    MotorR_REVERSE=0;
    MotorR_FORWARD=1;
    MotorL_FORWARD=1;
    wait(0.5);
    MotorR_FORWARD=0;
    wait(0.5);
    MotorL_FORWARD=0;
    MotorL_REVERSE=1;
    MotorR_REVERSE=1;  
    }} 
    
   
} }