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
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 unsigned int state = 0; 00013 void toggleYellow() 00014 { 00015 if (state == 0) { 00016 binaryOutput = kYELLOW; 00017 state = 1; 00018 } else { 00019 binaryOutput = 0; 00020 state = 0; 00021 } 00022 } 00023 00024 //The main function - all executable C / C++ 00025 //applications have a main function. This is 00026 //out entry point in the software 00027 Ticker T; 00028 00029 int main() { 00030 00031 binaryOutput = 0; 00032 00033 // ALL the code is contained in a 00034 // “while loop" 00035 00036 // THIS IS NOT AN IDEAL SOLUTION. HOWEVER IT IS SIMPLE 00037 00038 00039 while(1) 00040 { 00041 //The code between the { curly braces } 00042 //is the code that is repeated 00043 00044 //STATE 1 (R) 00045 binaryOutput = kRED; 00046 wait(4.0); 00047 00048 //STATE 2 (RA) 00049 binaryOutput = kRED + kYELLOW; 00050 wait(4.0); 00051 00052 //STATE 3 (G) 00053 binaryOutput = kGREEN; 00054 wait(4.0); 00055 00056 //STATE 4 (Flashing A) 00057 T.attach(toggleYellow, 0.25); 00058 wait(4.0); 00059 T.detach(); 00060 00061 } 00062 }
Generated on Sat Sep 17 2022 08:43:46 by
1.7.2