Task 3.5.1 Solution

Fork of Task351Solution by Nicholas Outram

Committer:
noutram
Date:
Wed Sep 18 12:46:23 2019 +0000
Revision:
2:035790cb9a00
Parent:
0:6858ff5fba1f
2019

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noutram 0:6858ff5fba1f 1 #include "mbed.h"
noutram 0:6858ff5fba1f 2
noutram 2:035790cb9a00 3 #ifdef TARGET_NUCLEO_F429ZI
noutram 2:035790cb9a00 4 //#define ONBOARD
noutram 2:035790cb9a00 5 #endif
noutram 2:035790cb9a00 6
noutram 2:035790cb9a00 7 #ifdef ONBOARD
noutram 2:035790cb9a00 8 BusOut binaryOutput(LED1, LED2, LED3);
noutram 2:035790cb9a00 9 #else
noutram 2:035790cb9a00 10 //Global objects
noutram 0:6858ff5fba1f 11 BusOut binaryOutput(D5, D6, D7);
noutram 2:035790cb9a00 12 #endif
noutram 0:6858ff5fba1f 13
noutram 0:6858ff5fba1f 14 /*
noutram 0:6858ff5fba1f 15 ***************************************************
noutram 0:6858ff5fba1f 16 Solution - use the post-decrement operator on iCount
noutram 0:6858ff5fba1f 17 ***************************************************
noutram 0:6858ff5fba1f 18 */
noutram 0:6858ff5fba1f 19
noutram 0:6858ff5fba1f 20 int main() {
noutram 0:6858ff5fba1f 21
noutram 0:6858ff5fba1f 22 int iCount = 7;
noutram 0:6858ff5fba1f 23
noutram 0:6858ff5fba1f 24 //Repeat this program forever
noutram 0:6858ff5fba1f 25 while(1) {
noutram 0:6858ff5fba1f 26
noutram 0:6858ff5fba1f 27 do {
noutram 0:6858ff5fba1f 28 binaryOutput = iCount--; //Write decimal to the output and decrement
noutram 0:6858ff5fba1f 29 wait(1.00); //Delay for 500ms
noutram 0:6858ff5fba1f 30 } while (iCount >= 0); //Condition to repeat
noutram 0:6858ff5fba1f 31
noutram 0:6858ff5fba1f 32 //Reset the count
noutram 0:6858ff5fba1f 33 iCount = 7;
noutram 0:6858ff5fba1f 34 }
noutram 0:6858ff5fba1f 35 }