Solution to Polling Exercise

Fork of digitalInPolling_sample by William Marsh

Revision:
3:914be74674bb
Parent:
2:cd1fe8c29793
diff -r cd1fe8c29793 -r 914be74674bb main.cpp
--- a/main.cpp	Tue Jan 16 18:02:44 2018 +0000
+++ b/main.cpp	Thu Feb 01 17:19:35 2018 +0000
@@ -14,6 +14,8 @@
 Thread pollT ; // thread to poll
 volatile int pressEvent = 0 ;  // Variabe set by the polling thread
 
+volatile int timez = 200 ;
+
 enum buttonPos { up, down, bounce }; // Button positions
 void polling() {
     buttonPos pos = up ;
@@ -54,10 +56,23 @@
     pollT.start(callback(polling));
 
     while(true) {
+        led = !led ;
         if (pressEvent) {
             pressEvent = 0 ; // clear the event variable
-            led = !led ;
+            
+            if (timez<1000)
+            {
+                timez+=200;     
+            }           
+            
+            else 
+            {
+                timez=200;
+            }    
         }
-        Thread::wait(100) ;
+        
+        Thread::wait(timez);
+                    
     }
-}
\ No newline at end of file
+}
+