elektro hiof / Mbed 2 deprecated Oppgave4-4

Dependencies:   mbed

Fork of Oppgave4-4 by elektro hiof

Revision:
1:e6e3af75f623
Parent:
0:c26cdf21261a
--- a/main.cpp	Fri Oct 17 11:48:37 2014 +0000
+++ b/main.cpp	Fri Oct 17 15:39:20 2014 +0000
@@ -1,27 +1,31 @@
 #include "mbed.h"
 DigitalOut LR(p18);
-DigitalIn  B1(p20);
-
+DigitalIn  B1(p15);
+float t = 2.0;
 int main()
 {
-    float i;
+
     while(1) {
-
-        while (B1==0) {
-
-            wait(2.0);
+        if(!B1)
+        {
+            t = 2.0;
+            wait(t);
             LR = 1;
-            wait(2.0);
+            wait(t);
             LR = 0;
         }
-        while(B1==1) {
-            if(i>=2.0) {
-                wait(i);
-                LR=1;
-                wait(0.2);
-                LR=0;
+        else
+        {
+           if(t >= 0.2)
+           {
+            t -= 0.2;
             }
-
+            wait(t);
+            LR = 1;
+            wait(0.2);
+            LR = 0;   
         }
     }
 }
+
+