Lights the barrery LED one-by-one, in an interval of 0.5 seconds. When button A is pressed, the LEDS hold.
main.cpp@4:7bb8fce3cdd6, 2016-05-14 (annotated)
- Committer:
- NoamVH
- Date:
- Sat May 14 13:58:05 2016 +0000
- Revision:
- 4:7bb8fce3cdd6
- Parent:
- 3:d57fdbf06ac8
Commenting reshaped for A4 page
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
NoamVH | 0:f74a732ac3ae | 1 | #include "mbed.h" |
NoamVH | 0:f74a732ac3ae | 2 | #include "TFC.h" |
NoamVH | 0:f74a732ac3ae | 3 | |
NoamVH | 3:d57fdbf06ac8 | 4 | int main() |
NoamVH | 3:d57fdbf06ac8 | 5 | { |
NoamVH | 2:61a8e97a0875 | 6 | TFC_Init(); //Initiate the TFC |
NoamVH | 2:61a8e97a0875 | 7 | int i=0; //Set counter to 0 |
NoamVH | 2:61a8e97a0875 | 8 | for(;;) { // Loop start |
NoamVH | 2:61a8e97a0875 | 9 | if(TFC_PUSH_BUTTON_0_PRESSED) //If button 0 is pressed |
NoamVH | 0:f74a732ac3ae | 10 | while(TFC_PUSH_BUTTON_0_PRESSED) { |
NoamVH | 4:7bb8fce3cdd6 | 11 | TFC_SetBatteryLED_Level(i); |
NoamVH | 4:7bb8fce3cdd6 | 12 | //Hold the battery leds on value i for |
NoamVH | 4:7bb8fce3cdd6 | 13 | //as long as the button is pressed |
NoamVH | 0:f74a732ac3ae | 14 | } |
NoamVH | 0:f74a732ac3ae | 15 | |
NoamVH | 2:61a8e97a0875 | 16 | else //If button 0 is NOT pressed |
NoamVH | 1:bb6a452620d1 | 17 | TFC_SetBatteryLED_Level(i); |
NoamVH | 3:d57fdbf06ac8 | 18 | wait(0.5); |
NoamVH | 3:d57fdbf06ac8 | 19 | if(i>4) |
NoamVH | 4:7bb8fce3cdd6 | 20 | i = 0; |
NoamVH | 4:7bb8fce3cdd6 | 21 | //Keep setting the to value i and increment i, |
NoamVH | 4:7bb8fce3cdd6 | 22 | //if i goes above 4, reset the LEDS |
NoamVH | 3:d57fdbf06ac8 | 23 | i++; |
NoamVH | 2:61a8e97a0875 | 24 | } //Loop end |
NoamVH | 2:61a8e97a0875 | 25 | } //Main end |
NoamVH | 0:f74a732ac3ae | 26 |