lab2-part1

Fork of digitalInPolling_sample by William Marsh

Revision:
3:28c7d280790e
Parent:
2:cd1fe8c29793
diff -r cd1fe8c29793 -r 28c7d280790e main.cpp
--- a/main.cpp	Tue Jan 16 18:02:44 2018 +0000
+++ b/main.cpp	Thu Feb 01 17:53:53 2018 +0000
@@ -8,7 +8,7 @@
 //   - Button bounce is guarded against
 // A second thread (the default one) checks for the press event and toggles the LED
 
-DigitalIn b1(PTD0, PullUp);
+DigitalIn b1(PTD0, PullUp);//change the address
 DigitalOut led(LED1);
 
 Thread pollT ; // thread to poll
@@ -49,15 +49,24 @@
 /*  ---- Main function (default thread) ----
     Note that if this thread completes, nothing else works
  */
-int main() {
-    led = 1 ;  // Initially off
+int main() 
+{
+    int speed = 1;    
+    led = 1 ; 
     pollT.start(callback(polling));
 
-    while(true) {
-        if (pressEvent) {
-            pressEvent = 0 ; // clear the event variable
-            led = !led ;
-        }
-        Thread::wait(100) ;
+    while(true) 
+    {
+        if (pressEvent)
+        { 
+            speed++;
+            
+            if (speed >= 5)
+                speed = 1;
+            
+            pressEvent = 0;
+        } 
+        led = !led ;
+        Thread::wait(200*speed);
     }
-}
\ No newline at end of file
+}