Task 3.3.2 Solution
Fork of Task332Solution by
main.cpp@2:650196238978, 2019-09-18 (annotated)
- Committer:
- noutram
- Date:
- Wed Sep 18 11:58:31 2019 +0000
- Revision:
- 2:650196238978
- Parent:
- 0:7b9a83230461
2019
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| noutram | 0:7b9a83230461 | 1 | #include "mbed.h" |
| noutram | 0:7b9a83230461 | 2 | |
| noutram | 2:650196238978 | 3 | #ifdef TARGET_NUCLEO_F429ZI |
| noutram | 2:650196238978 | 4 | //#define ONBOARD |
| noutram | 2:650196238978 | 5 | #endif |
| noutram | 2:650196238978 | 6 | |
| noutram | 2:650196238978 | 7 | #ifdef ONBOARD |
| noutram | 2:650196238978 | 8 | BusOut binaryOutput(LED1, LED2, LED3); |
| noutram | 2:650196238978 | 9 | #else |
| noutram | 2:650196238978 | 10 | //lsb first |
| noutram | 0:7b9a83230461 | 11 | BusOut binaryOutput(D5, D6, D7); |
| noutram | 2:650196238978 | 12 | #endif |
| noutram | 0:7b9a83230461 | 13 | |
| noutram | 0:7b9a83230461 | 14 | int main() { |
| noutram | 0:7b9a83230461 | 15 | |
| noutram | 0:7b9a83230461 | 16 | int iCount = 7; |
| noutram | 0:7b9a83230461 | 17 | |
| noutram | 0:7b9a83230461 | 18 | while(1) { |
| noutram | 0:7b9a83230461 | 19 | |
| noutram | 0:7b9a83230461 | 20 | do { |
| noutram | 0:7b9a83230461 | 21 | //Write decimal to the output |
| noutram | 0:7b9a83230461 | 22 | binaryOutput = iCount; |
| noutram | 0:7b9a83230461 | 23 | |
| noutram | 0:7b9a83230461 | 24 | //Increment the count |
| noutram | 0:7b9a83230461 | 25 | iCount = iCount - 1; |
| noutram | 0:7b9a83230461 | 26 | wait(1.0); //Delay for 1s |
| noutram | 0:7b9a83230461 | 27 | |
| noutram | 0:7b9a83230461 | 28 | //Condition to repeat |
| noutram | 0:7b9a83230461 | 29 | } while (iCount >= 0); |
| noutram | 0:7b9a83230461 | 30 | |
| noutram | 0:7b9a83230461 | 31 | //Reset the count |
| noutram | 0:7b9a83230461 | 32 | iCount = 7; |
| noutram | 0:7b9a83230461 | 33 | |
| noutram | 0:7b9a83230461 | 34 | } //end while(1) |
| noutram | 0:7b9a83230461 | 35 | } //end main |
