Task 3.3.2 Solution
Dependencies: mbed
main.cpp@0:7b9a83230461, 2015-09-24 (annotated)
- Committer:
- noutram
- Date:
- Thu Sep 24 12:26:13 2015 +0000
- Revision:
- 0:7b9a83230461
Initial version 24-09-2015
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 | 0:7b9a83230461 | 3 | BusOut binaryOutput(D5, D6, D7); |
noutram | 0:7b9a83230461 | 4 | //DigitalIn SW1(D4); |
noutram | 0:7b9a83230461 | 5 | |
noutram | 0:7b9a83230461 | 6 | int main() { |
noutram | 0:7b9a83230461 | 7 | |
noutram | 0:7b9a83230461 | 8 | int iCount = 7; |
noutram | 0:7b9a83230461 | 9 | |
noutram | 0:7b9a83230461 | 10 | while(1) { |
noutram | 0:7b9a83230461 | 11 | |
noutram | 0:7b9a83230461 | 12 | do { |
noutram | 0:7b9a83230461 | 13 | //Write decimal to the output |
noutram | 0:7b9a83230461 | 14 | binaryOutput = iCount; |
noutram | 0:7b9a83230461 | 15 | |
noutram | 0:7b9a83230461 | 16 | //Increment the count |
noutram | 0:7b9a83230461 | 17 | iCount = iCount - 1; |
noutram | 0:7b9a83230461 | 18 | wait(1.0); //Delay for 1s |
noutram | 0:7b9a83230461 | 19 | |
noutram | 0:7b9a83230461 | 20 | //Condition to repeat |
noutram | 0:7b9a83230461 | 21 | } while (iCount >= 0); |
noutram | 0:7b9a83230461 | 22 | |
noutram | 0:7b9a83230461 | 23 | //Reset the count |
noutram | 0:7b9a83230461 | 24 | iCount = 7; |
noutram | 0:7b9a83230461 | 25 | |
noutram | 0:7b9a83230461 | 26 | } //end while(1) |
noutram | 0:7b9a83230461 | 27 | } //end main |