Lights the barrery LED one-by-one, in an interval of 0.5 seconds. When button A is pressed, the LEDS hold.

Dependencies:   FRDM-TFC mbed

Revision:
2:61a8e97a0875
Parent:
1:bb6a452620d1
Child:
3:d57fdbf06ac8
--- a/main.cpp	Sat Feb 27 13:57:43 2016 +0000
+++ b/main.cpp	Sat Feb 27 14:02:15 2016 +0000
@@ -1,22 +1,21 @@
 #include "mbed.h"
 #include "TFC.h"
 
-int main()
-{
-    TFC_Init();
-    int i=0;
-    for(;;) {
-        if(TFC_PUSH_BUTTON_0_PRESSED)
+int main() {
+    TFC_Init(); //Initiate the TFC
+    int i=0; //Set counter to 0
+    for(;;) { // Loop start
+        if(TFC_PUSH_BUTTON_0_PRESSED) //If button 0 is pressed
             while(TFC_PUSH_BUTTON_0_PRESSED) {
-                TFC_SetBatteryLED_Level(i);
+                TFC_SetBatteryLED_Level(i); //Hold the battery leds on value i as long as the button is pressed
             }
 
-        else
+        else //If button 0 is NOT pressed
             TFC_SetBatteryLED_Level(i);
             wait(0.5);
             if(i>4)
-                i = 0;
+                i = 0; //Keep setting the to value i and increment i, if i goes above 4, reset the LEDS
     i++;
-    }
-}
+    } //Loop end
+} //Main end