Marcin Sławicz / Mbed 2 deprecated DISCO-L072CZ-LRWAN1_blink_leds

Dependencies:   mbed

Revision:
2:603a8ac68090
Parent:
1:d343cf676574
Child:
3:50a3fc3bce95
--- a/main.cpp	Wed May 17 09:17:45 2017 +0200
+++ b/main.cpp	Mon May 29 15:10:02 2017 +0200
@@ -7,22 +7,25 @@
 
 InterruptIn mybutton(USER_BUTTON);
 
-double tempo = 0.2;    //time to wait
+double tempo = 0.2; // LED blinking delay
 
-void changetempo() {   
-	if(tempo == 0.2)   // If leds have low frequency
-		tempo = 0.1;   // Set the fast frequency
-	else               // If les have fast frequency
-		tempo = 0.2;   // Set the low frequency
+// Change LEDs blinking frequency
+void change_blinking_frequency() {
+    if (tempo == 0.3) // If leds have low frequency
+        tempo = 0.1;  // Set the fast frequency
+    else              // If leds have fast frequency
+        tempo = 0.3;  // Set the low frequency
 }
 
 int main() {
-	myled1 = 0;            //LED1 is OFF
-	myled2 = 0;            //LED2 is OFF
-	myled3 = 0;            //LED3 is OFF
-	myled4 = 0;            //LED4 is OFF
+    // All LEDs are OFF
+    myled1 = 0;
+    myled2 = 0;
+    myled3 = 0;
+    myled4 = 0;
 
-    mybutton.fall(&changetempo);  //Interrupt to change tempo
+    // Change LEDs blinking frequency when button is pressed
+    mybutton.fall(&change_blinking_frequency);
 
     while(1) {
         myled2 = 1;   // LED2 is ON