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 #include "mbed.h" 00002 00003 // 00004 //This is my first code for the Mbed. It's also my first c++ program. 00005 //It is based on ABetterHelloWorld by Andrew Harpin 00006 //The 4 LEDS on the Mbed repeatedly count in binary from 0 to 15 00007 // 00008 // 00009 DigitalOut myled1(LED1); 00010 DigitalOut myled2(LED2); 00011 DigitalOut myled3(LED3); 00012 DigitalOut myled4(LED4); 00013 Timer mytimer; 00014 00015 int main() 00016 { 00017 myled1 = 1; 00018 myled2 = 1; 00019 myled3 = 1; 00020 myled4 = 1; 00021 mytimer.start(); 00022 00023 int intStart = mytimer.read_ms(); 00024 int intCounter = 0; 00025 bool blnSetalloff = true; 00026 while(1) 00027 { 00028 if((mytimer.read_ms() - intStart) >= 250) 00029 { 00030 if (blnSetalloff) 00031 { 00032 myled1 = 0; 00033 myled2 = 0; 00034 myled3 = 0; 00035 myled4 = 0; 00036 blnSetalloff = false; 00037 continue; 00038 } 00039 00040 if (intCounter % 16 > 7) 00041 { 00042 myled1 = 1; 00043 } 00044 if (intCounter % 8 > 3) 00045 { 00046 myled2 = 1; 00047 } 00048 if (intCounter % 4 > 1) 00049 { 00050 myled3 = 1; 00051 } 00052 if (intCounter % 2 == 1) 00053 { 00054 myled4 = 1; 00055 } 00056 intCounter +=1; 00057 blnSetalloff = true; 00058 intStart = mytimer.read_ms(); 00059 } 00060 } 00061 }
Generated on Wed Jul 13 2022 07:08:39 by
1.7.2