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