Bertl16-cross

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
WelzAlex
Date:
Thu Jun 16 16:43:31 2016 +0000
Commit message:
forward-->back-->turn right-->forward-->back-->turn left-->back-->forward-->turn right-->back-->forward-->turn left (loop)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 41f8d348b90d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 16 16:43:31 2016 +0000
@@ -0,0 +1,617 @@
+//while(1){ VOR (weiss)_ZURUECK(rot)_RECHTS(blinker) }
+
+#include "mbed.h"
+
+
+DigitalOut Von(P2_13);       // 12V on
+// Definition der 12 LED's 
+DigitalOut WSLI(P1_10);     //wsS links  D1
+DigitalOut WSRE(P1_12);     //wsS rechts D4
+DigitalOut GELIVO (P1_11);  //ge links vorn D2
+DigitalOut GEREVO (P1_13);  //ge rechts vorn D5
+DigitalOut GELIHI(P1_14);   //ge links hinten D6
+DigitalOut RTLIHI(P1_15);   // rt links hinbten D7        
+DigitalOut GEREHI(P1_16);   //ge rechts hinten D8
+DigitalOut RTREHI(P1_17);   //rt  rechts hinten D9
+
+DigitalOut ledD10 (P1_18);     
+DigitalOut ledD11 (P2_16);
+DigitalOut ledD12 (P1_20);
+DigitalOut ledD13 (P1_21);
+
+// LDR 
+AnalogIn LDR(P0_14);
+// RGB LED
+DigitalOut RGB(P1_22);
+// Motor Steuerung                    Schaltung Pg 2
+DigitalOut MG1_EN(P2_16);// NUR DIGITAL ohne PWM ! ! !
+DigitalOut MG1_F(P2_15);
+DigitalOut MG1_R(P2_14);
+DigitalOut MG2_EN(P2_19);
+DigitalOut MG2_F(P2_20);
+DigitalOut MG2_R(P2_21);
+//ULTRASCHALL ABSTANDSMESSER
+DigitalOut TRIG(P2_22);
+DigitalIn ECHO(P2_23);
+// Definition der Taster **************** Schaltplan Pg5
+DigitalIn  TA1(P1_23); //TA1
+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); // 
+// INCREMENTGEBER  *********************** Schaltplan Pg 6
+DigitalOut EN_INCR (P2_2);  //Incrementgeber Enable
+DigitalIn INCR_L1 (P2_6);
+DigitalIn INCR_L2 (P2_7); 
+DigitalIn INCR_R1 (P2_8);  
+DigitalIn INCR_R2 (P2_9); 
+// LINE SENSOR *************************** Schaltplan Pg 7
+DigitalOut EN_Line (P2_5); //Enable LINE Sensor
+DigitalIn ISO1 (P1_9);  // Statt ANALOG hier DIGITAL
+DigitalIn ISO2 (P0_23); // nur für einfachen TEST!
+DigitalIn ISO3 (P0_16);
+DigitalIn ISO4 (P0_15);
+DigitalIn ISO5 (P1_3);
+// Blue LED ****************************** Schaltplan Pg 8
+DigitalOut LedBl (P1_5);
+
+
+
+
+int main() 
+{
+
+
+//ALLE LEDS aus
+        GELIHI=1; //Gelb links hinten
+        GEREHI=1;//gelb rehts hinten
+        RTREHI=1;//Rot rechts hinten
+        RTLIHI=1; //rot links hinten       
+        GELIVO=1;//gelb links vorne
+        GEREVO=1;//gelb rechts hinten
+        WSLI=1;//weiss links vorne
+        WSRE=1;//weiss rechts vorne
+        ledD10=1;
+        ledD11=1;
+        ledD13=1;
+        ledD12=1;
+        
+    Von =1;
+    MG1_EN=MG2_EN=1;
+    
+    
+    
+    
+    
+while(1)//Hauptschleife
+{
+        
+        int c=0;
+        int d=0;
+        int e=0;
+        int f=0; 
+    
+    //1 Schleife (vor-zurück-90°rechts)
+    while(c<1)
+    {
+    
+         
+         
+        int i = 0;
+        int a = 0;
+        int b = 0;
+    
+        MG1_F=MG2_F=1;
+    
+        //LED links nach rechts
+        while(i<1) 
+        {
+        
+            WSLI=0;
+            WSRE=0;     
+            ledD10=0;
+            wait (0.2);
+            ledD10=1;
+    
+        
+    
+            ledD11=0;
+            wait (0.2);
+            ledD11=1;
+    
+        
+        
+    
+            ledD13=0;
+            wait (0.2);
+            ledD13=1;
+        
+        
+    
+            ledD12=0;
+            wait (0.2);
+            ledD12=1;
+        
+            WSLI=1;
+            WSRE=1;
+    
+            i++;   
+        }    
+
+        
+        MG1_F=MG2_F=0;
+        wait(0.1);
+        MG1_R=MG2_R=1;
+    
+
+        //LED rechts nach links
+        while(a<1) 
+        {
+        
+            RTREHI=0;//Rot rechts hinten
+            RTLIHI=0; //rot links hinten 
+    
+            ledD12=0;
+            wait (0.2);
+            ledD12=1;
+        
+        
+              
+            ledD13=0;
+            wait (0.2);
+            ledD13=1;
+    
+    
+        
+    
+            ledD11=0;
+            wait (0.2);
+            ledD11=1;
+
+        
+    
+            ledD10=0;
+            wait(0.2);
+            ledD10=1;
+        
+            RTREHI=1;//Rot rechts hinten
+            RTLIHI=1; //rot links hinten 
+        
+            a++;   
+        }
+
+
+    
+        MG1_R=MG2_R=0;
+        wait(0.75);
+        
+        //Blinker Rechts Vorn/Hinten
+        while(b<2)
+        {
+            GEREVO=0;
+            GEREHI=0;
+            wait(0.05);
+            GEREVO=1;
+            GEREHI=1;
+            wait(0.05);
+            GEREVO=0;
+            GEREHI=0;
+            wait(0.05);
+            GEREVO=1;
+            GEREHI=1;
+            wait(0.05);
+            GEREVO=0;
+            GEREHI=0;
+            wait(0.05);
+            GEREVO=1;
+            GEREHI=1;
+            wait(0.05);
+            b++;
+        }
+        
+        //90° Drehung (rechts)
+        MG1_F=MG2_R=1;
+    
+        wait(0.5555555);
+    
+        MG1_F=MG2_R=0;
+        wait(0.5);
+    
+        c++;
+        }
+
+
+
+
+
+
+        //2 Schleife (vor-zurück-90°links)
+        while(d<1)
+        {
+            int i = 0;
+            int a = 0;
+            int b = 0;
+            MG1_F=MG2_F=1;
+    
+        //LED links nach rechts
+        while(i<1) 
+        {
+        
+            WSLI=0;
+            WSRE=0;     
+            ledD10=0;
+            wait (0.2);
+            ledD10=1;
+    
+        
+    
+            ledD11=0;
+            wait (0.2);
+            ledD11=1;
+    
+        
+        
+    
+            ledD13=0;
+            wait (0.2);
+            ledD13=1;
+        
+        
+    
+            ledD12=0;
+            wait (0.2);
+            ledD12=1;
+        
+            WSLI=1;
+            WSRE=1;
+    
+            i++;   
+        }    
+
+    
+        MG1_F=MG2_F=0;
+        wait(0.1);
+        MG1_R=MG2_R=1;
+    
+
+        //LED rechts nach links
+        while(a<1) 
+        {
+        
+            RTREHI=0;//Rot rechts hinten
+            RTLIHI=0; //rot links hinten 
+    
+            ledD12=0;
+            wait (0.2);
+            ledD12=1;
+        
+        
+              
+            ledD13=0;
+            wait (0.2);
+            ledD13=1;
+    
+    
+        
+    
+            ledD11=0;
+            wait (0.2);
+            ledD11=1;
+
+        
+    
+            ledD10=0;
+            wait(0.2);
+            ledD10=1;
+        
+            RTREHI=1;//Rot rechts hinten
+            RTLIHI=1; //rot links hinten 
+        
+            a++;   
+        }
+
+
+    
+        MG1_R=MG2_R=0;
+        wait(0.75);
+        
+        //Blinker Links Vorn/Hinten
+        while(b<2)
+        {
+            GELIVO=0;
+            GELIHI=0;
+            wait(0.05);
+            GELIVO=1;
+            GELIHI=1;
+            wait(0.05);
+            GELIVO=0;
+            GELIHI=0;
+            wait(0.05);
+            GELIVO=1;
+            GELIHI=1;
+            wait(0.05);
+            GELIVO=0;
+            GELIHI=0;
+            wait(0.05);
+            GELIVO=1;
+            GELIHI=1;
+            wait(0.05);
+            b++;
+        }
+        
+        //90° Drehung (links)
+        MG1_R=MG2_F=1;
+    
+        wait(0.5555555);
+    
+        MG1_R=MG2_F=0;
+        wait(0.5);
+    
+        d++;
+    }
+    
+    //3.Schleife (zurück-vor-90°links)
+    while(e<1)
+    {
+            int i = 0;
+            int a = 0;
+            int b = 0;
+            
+            MG1_R=MG2_R=1;
+        
+        //LED rechts nach links
+        while(a<1) 
+        {
+        
+            RTREHI=0;//Rot rechts hinten
+            RTLIHI=0; //rot links hinten 
+    
+            ledD12=0;
+            wait (0.2);
+            ledD12=1;
+        
+        
+              
+            ledD13=0;
+            wait (0.2);
+            ledD13=1;
+    
+    
+        
+    
+            ledD11=0;
+            wait (0.2);
+            ledD11=1;
+
+        
+    
+            ledD10=0;
+            wait(0.2);
+            ledD10=1;
+        
+            RTREHI=1;//Rot rechts hinten
+            RTLIHI=1; //rot links hinten 
+        
+            a++;   
+        }
+
+
+    
+        MG1_R=MG2_R=0;
+        wait(0.1);
+        MG1_F=MG2_F=1;
+        
+   
+        //LED links nach rechts
+        while(i<1) 
+        {
+        
+            WSLI=0;
+            WSRE=0;     
+            ledD10=0;
+            wait(0.2);
+            ledD10=1;
+    
+        
+    
+            ledD11=0;
+            wait(0.2);
+            ledD11=1;
+    
+        
+        
+    
+            ledD13=0;
+            wait(0.2);
+            ledD13=1;
+        
+        
+    
+            ledD12=0;
+            wait(0.2);
+            ledD12=1;
+        
+            WSLI=1;
+            WSRE=1;
+    
+            i++;   
+        }    
+
+    
+        MG1_F=MG2_F=0;
+        wait(0.75);
+        
+    
+        
+        //Blinker Rechts Vorn/Hinten
+        while(b<2)
+        {
+            GEREVO=0;
+            GEREHI=0;
+            wait(0.05);
+            GEREVO=1;
+            GEREHI=1;
+            wait(0.05);
+            GEREVO=0;
+            GEREHI=0;
+            wait(0.05);
+            GEREVO=1;
+            GEREHI=1;
+            wait(0.05);
+            GEREVO=0;
+            GEREHI=0;
+            wait(0.05);
+            GEREVO=1;
+            GEREHI=1;
+            wait(0.05);
+            b++;
+        }
+        
+        //90° Drehung (rechts)
+        MG1_F=MG2_R=1;
+    
+        wait(0.5555555);
+    
+        MG1_F=MG2_R=0;
+        wait(0.5);
+    
+        e++;
+    }
+    
+    //4.Schleife (zurück-vorn-90°links)
+    while(f<1)
+    {
+            int i = 0;
+            int a = 0;
+            int b = 0;
+            MG1_R=MG2_R=1;
+            
+        //LED rechts nach links
+        while(a<1) 
+        {
+        
+            RTREHI=0;//Rot rechts hinten
+            RTLIHI=0; //rot links hinten 
+    
+            ledD12=0;
+            wait (0.2);
+            ledD12=1;
+        
+        
+              
+            ledD13=0;
+            wait (0.2);
+            ledD13=1;
+    
+    
+        
+    
+            ledD11=0;
+            wait (0.2);
+            ledD11=1;
+
+        
+    
+            ledD10=0;
+            wait(0.2);
+            ledD10=1;
+        
+            RTREHI=1;//Rot rechts hinten
+            RTLIHI=1; //rot links hinten 
+        
+            a++;   
+        }
+        
+        MG1_R=MG2_R=0;
+        wait(0.1);
+        MG1_F=MG2_F=1;
+        
+        //LED links nach rechts
+        while(i<1) 
+        {
+        
+            WSLI=0;
+            WSRE=0;     
+            ledD10=0;
+            wait (0.2);
+            ledD10=1;
+    
+        
+    
+            ledD11=0;
+            wait (0.2);
+            ledD11=1;
+    
+        
+        
+    
+            ledD13=0;
+            wait (0.2);
+            ledD13=1;
+        
+        
+    
+            ledD12=0;
+            wait (0.2);
+            ledD12=1;
+        
+            WSLI=1;
+            WSRE=1;
+    
+            i++;   
+        }    
+
+    
+        MG1_F=MG2_F=0;
+        wait(0.75);
+        
+        //Blinker Links Vorn/Hinten
+        while(b<2)
+        {
+            GELIVO=0;
+            GELIHI=0;
+            wait(0.05);
+            GELIVO=1;
+            GELIHI=1;
+            wait(0.05);
+            GELIVO=0;
+            GELIHI=0;
+            wait(0.05);
+            GELIVO=1;
+            GELIHI=1;
+            wait(0.05);
+            GELIVO=0;
+            GELIHI=0;
+            wait(0.05);
+            GELIVO=1;
+            GELIHI=1;
+            wait(0.05);
+            b++;
+        }
+        
+        //90° Drehung (links)
+        MG1_R=MG2_F=1;
+    
+        wait(0.5555555);
+    
+        MG1_R=MG2_F=0;
+        wait(0.5);
+    
+        f++;
+    } 
+    
+    
+    
+    
+    
+    
+
+}
+
+
+
+
+}
diff -r 000000000000 -r 41f8d348b90d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jun 16 16:43:31 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file