Lights the barrery LED one-by-one, in an interval of 0.5 seconds. When button A is pressed, the LEDS hold.
main.cpp@3:d57fdbf06ac8, 2016-02-27 (annotated)
- Committer:
- NoamVH
- Date:
- Sat Feb 27 14:11:59 2016 +0000
- Revision:
- 3:d57fdbf06ac8
- Parent:
- 2:61a8e97a0875
- Child:
- 4:7bb8fce3cdd6
Foramtted.
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 | 2:61a8e97a0875 | 11 | TFC_SetBatteryLED_Level(i); //Hold the battery leds on value i as long as the button is pressed |
NoamVH | 0:f74a732ac3ae | 12 | } |
NoamVH | 0:f74a732ac3ae | 13 | |
NoamVH | 2:61a8e97a0875 | 14 | else //If button 0 is NOT pressed |
NoamVH | 1:bb6a452620d1 | 15 | TFC_SetBatteryLED_Level(i); |
NoamVH | 3:d57fdbf06ac8 | 16 | wait(0.5); |
NoamVH | 3:d57fdbf06ac8 | 17 | if(i>4) |
NoamVH | 3:d57fdbf06ac8 | 18 | i = 0; //Keep setting the to value i and increment i, if i goes above 4, reset the LEDS |
NoamVH | 3:d57fdbf06ac8 | 19 | i++; |
NoamVH | 2:61a8e97a0875 | 20 | } //Loop end |
NoamVH | 2:61a8e97a0875 | 21 | } //Main end |
NoamVH | 0:f74a732ac3ae | 22 |