Nicholas Outram / Mbed OS Task351Solution
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 BusOut binaryOutput(D5, D6, D7);
00004 
00005 /*
00006  ***************************************************
00007 Solution - use the post-decrement operator on iCount
00008  ***************************************************
00009  */
00010 
00011 int main() {
00012     
00013     int iCount = 7;
00014     
00015     //Repeat this program forever
00016     while(1) {
00017         
00018         do {
00019             binaryOutput = iCount--;  //Write decimal to the output and decrement
00020             wait(1.00);             //Delay for 500ms
00021         } while (iCount >= 0);      //Condition to repeat
00022         
00023         //Reset the count
00024         iCount = 7;
00025     }
00026 }