University of Plymouth - Stages 1, 2 and 3
/
Task351Solution
Task 3.5.1 Solution
Fork of Task351Solution by
main.cpp@0:6858ff5fba1f, 2015-09-24 (annotated)
- Committer:
- noutram
- Date:
- Thu Sep 24 12:27:45 2015 +0000
- Revision:
- 0:6858ff5fba1f
- Child:
- 2:035790cb9a00
Initial version 24-09-2015
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
noutram | 0:6858ff5fba1f | 1 | #include "mbed.h" |
noutram | 0:6858ff5fba1f | 2 | |
noutram | 0:6858ff5fba1f | 3 | BusOut binaryOutput(D5, D6, D7); |
noutram | 0:6858ff5fba1f | 4 | |
noutram | 0:6858ff5fba1f | 5 | /* |
noutram | 0:6858ff5fba1f | 6 | *************************************************** |
noutram | 0:6858ff5fba1f | 7 | Solution - use the post-decrement operator on iCount |
noutram | 0:6858ff5fba1f | 8 | *************************************************** |
noutram | 0:6858ff5fba1f | 9 | */ |
noutram | 0:6858ff5fba1f | 10 | |
noutram | 0:6858ff5fba1f | 11 | int main() { |
noutram | 0:6858ff5fba1f | 12 | |
noutram | 0:6858ff5fba1f | 13 | int iCount = 7; |
noutram | 0:6858ff5fba1f | 14 | |
noutram | 0:6858ff5fba1f | 15 | //Repeat this program forever |
noutram | 0:6858ff5fba1f | 16 | while(1) { |
noutram | 0:6858ff5fba1f | 17 | |
noutram | 0:6858ff5fba1f | 18 | do { |
noutram | 0:6858ff5fba1f | 19 | binaryOutput = iCount--; //Write decimal to the output and decrement |
noutram | 0:6858ff5fba1f | 20 | wait(1.00); //Delay for 500ms |
noutram | 0:6858ff5fba1f | 21 | } while (iCount >= 0); //Condition to repeat |
noutram | 0:6858ff5fba1f | 22 | |
noutram | 0:6858ff5fba1f | 23 | //Reset the count |
noutram | 0:6858ff5fba1f | 24 | iCount = 7; |
noutram | 0:6858ff5fba1f | 25 | } |
noutram | 0:6858ff5fba1f | 26 | } |