Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Task352Solution by
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 DigitalIn SW1(D3); 00007 DigitalIn SW2(D4); 00008 00009 //Main function 00010 int main() { 00011 00012 //Create a variable to hold the bit pattern 00013 unsigned int u = 7; 00014 00015 while(1) { 00016 00017 binaryOutput = u; //Write to LEDs 00018 00019 //TOGGLE all 3 bits in u 00020 u = u ^ 7; 00021 00022 //Calculate the delay 00023 int binaryInput = SW1 + (SW2 << 1); 00024 double delay = (double)(binaryInput+1); 00025 wait(delay * 0.25); //Wait 00026 00027 } //end while(1) 00028 } //end main
Generated on Sat Jul 16 2022 21:13:55 by
1.7.2