Projekt TEINF

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Reichi19
Date:
Thu Nov 29 18:44:44 2018 +0000
Parent:
2:23fc7c5e314a
Commit message:
Projekt TINF 1.3

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 23fc7c5e314a -r ccacc13998da main.cpp
--- a/main.cpp	Thu Nov 29 17:59:15 2018 +0000
+++ b/main.cpp	Thu Nov 29 18:44:44 2018 +0000
@@ -4,20 +4,22 @@
 DigitalOut led2(LED2);
 DigitalOut led3(LED3);
 DigitalOut led4(LED4);
-
+BusOut led (LED1,LED2,LED3,LED4);
 InterruptIn sw1(p14);
 InterruptIn sw2(p15);
 
+void flipper(void);
 void ON(void);
 void OFF(void);
+void IDEL(void);
 void sw1Rise(void);
 bool checker(void);
 bool volatile sw1Pressed;
 
 
-int zustand;
-
-enum Status{ST_ON=0, ST_OFF};
+int counter;
+int i = 0;
+enum Status{ST_ON = 0, ST_OFF};
 Status volatile status;
 
 int main(void)
@@ -25,7 +27,7 @@
     sw1.rise(&sw1Rise);
     status = ST_ON;
     sw1Pressed = 0;
-    zustand=0;
+    counter =0;
     led1=0, led2=0, led3=0, led4=0;
     
     while(1)
@@ -38,30 +40,27 @@
     }
 }
 
+void flipper(void)
+{
+    if(counter == 1)
+    { 
+        int i;
+        i++;
+        
+        led = i;
+        
+    }
+    counter ++;
+}
+
+
+
 bool checker(void)
 {
-
-        if(sw1Pressed == true)
-    {
-        zustand=1; 
-        wait_ms(200);
-    }
-    
-        else if(sw1Pressed == true)
-    {
-        zustand=2; 
-        wait_ms(200);
-    }
-        else if(sw1Pressed == true)
-    {
-        zustand=3; 
-        wait_ms(200);
-    }
-    
-    else if(zustand == 3)
+ 
+ if(sw1Pressed == 1)
     {
         printf("void checker\n");
-        zustand = 0;
         sw1Pressed = false;
         return true;
     }
@@ -83,14 +82,13 @@
 void OFF(void)
 {
     printf("void OFF\n");
-    led1 = 0, led2=0, led3=0,led4=0;
+    led =0;
     
     while(1)
     {
         if (checker() == true)
         {
             status = ST_ON;
-            led1=false;
             return;
         }
     }
@@ -98,17 +96,26 @@
 
 void ON(void)
 {
-    printf("void ON\n");
-    led1 = 1, led2=1, led3=1,led4=1;
+
+    led = 15;
     wait_ms(500);
-    led1 = 0, led2=0;
-    while(1)
+    led = 3;
+
+    
+    
+    printf("void ON\n");
+     
+     while(1)
     {
-        if (checker() == true)
+         if (checker() == true)
         {
+            flipper();
             status = ST_OFF;
+            
             return;
+            
         }
 
     }
-}
\ No newline at end of file
+}
+