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

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 //Global objects
00004 BusOut binaryOutput(D5, D6, D7);
00005 
00006 
00007 //Main function
00008 int main() {
00009 
00010     //Create a variable to hold the bit pattern
00011     unsigned int u;
00012 
00013     while(1) {
00014         
00015         u = 1;             //Set initial value 0
00016         int count = 0;
00017         while (count++ < 3) {
00018            binaryOutput = u;    //Write to LEDs
00019            u = u << 1;          //Shift left 1 bit
00020            wait(0.25);          //Wait
00021         }       
00022         
00023         //At this point, the output is binary 100
00024         //Change to 010
00025         binaryOutput = 2;   //The missing yellow state
00026         wait(0.25); 
00027         
00028         //The sequence can now repeat
00029     } //end while(1)
00030 } //end main