Nicholas Outram / Mbed OS Task352
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);    //Outputs as an integer
00005 BusIn binaryInput(D3, D4);          //Inputs as an integer
00006 
00007 
00008 //Main function
00009 int main() {
00010 
00011     //Create a variable to hold the bit pattern
00012     unsigned int u = 7;
00013 
00014     while(1) {
00015                  
00016         binaryOutput = u;    //Write to LEDs
00017            
00018         //TOGGLE all 3 bits in u
00019         u = u ^ 7;
00020            
00021         //Calculate the delay     
00022         double delay = (double)(binaryInput+1);
00023         wait(delay * 0.25);          //Wait
00024             
00025     } //end while(1)
00026 } //end main