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.
main.cpp
00001 //This is known as a “header file” 00002 //In short, this copies and pastes the text file 00003 //mbed.h into this code 00004 #include "mbed.h" 00005 00006 #define kRED 1 00007 #define kYELLOW 2 00008 #define kGREEN 4 00009 00010 BusOut binaryOutput(D7, D6, D5); //Outputs as an integer 00011 00012 //The main function - all executable C / C++ 00013 //applications have a main function. This is 00014 //out entry point in the software 00015 Ticker T; 00016 00017 int main() { 00018 00019 binaryOutput = 0; 00020 00021 // ALL the code is contained in a 00022 // “while loop" 00023 00024 // THIS IS NOT AN IDEAL SOLUTION. HOWEVER IT IS SIMPLE 00025 00026 00027 while(1) 00028 { 00029 //The code between the { curly braces } 00030 //is the code that is repeated 00031 00032 //STATE 1 (R) 00033 binaryOutput = kRED; 00034 wait(1.0); 00035 00036 //STATE 2 (RA) 00037 binaryOutput = kRED + kYELLOW; 00038 wait(1.0); 00039 00040 //STATE 3 (G) 00041 binaryOutput = kGREEN; 00042 wait(1.0); 00043 00044 //STATES 4-7 (Flashing A) 00045 binaryOutput = kYELLOW; 00046 wait(0.25); 00047 binaryOutput = 0; 00048 wait(0.25); 00049 binaryOutput = kYELLOW; 00050 wait(0.25); 00051 binaryOutput = 0; 00052 wait(0.25); 00053 00054 } 00055 }
Generated on Mon Jul 18 2022 02:11:03 by
1.7.2