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 // LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23 00004 00005 #define SPEED 0.125 00006 00007 #define LED_MASK 0x00B40000 00008 #define LED1 0x00040000 00009 #define LED2 0x00100000 00010 #define LED3 0x00200000 00011 #define LED4 0x00800000 00012 void setled(char); 00013 00014 00015 int ledarray[]={LED1,LED2,LED3,LED4}; 00016 00017 PortOut ledport(Port1, LED_MASK); 00018 00019 int main() { 00020 char a=1; 00021 00022 while(1) 00023 { 00024 while (a<8) 00025 { 00026 setled(a); 00027 wait(SPEED); 00028 setled(0); 00029 a<<=1; 00030 } 00031 while (a>1) 00032 { 00033 setled(a); 00034 wait(SPEED); 00035 setled(0); 00036 a>>=1; 00037 } 00038 } 00039 } 00040 00041 void setled(char value) 00042 { 00043 int mask=0; 00044 00045 for (int i=0;i<4;i++) 00046 { 00047 if (value&1) 00048 { 00049 mask|=ledarray[i]; 00050 } 00051 value>>=1; 00052 } 00053 ledport=mask; 00054 }
Generated on Fri Jul 15 2022 05:13:35 by
1.7.2