David Geenen
/
LED11_Lightshow
User defined (4) LED changing display
Revision 0:5e02d10d8d58, committed 2010-11-21
- Comitter:
- djgeenen
- Date:
- Sun Nov 21 20:01:49 2010 +0000
- Commit message:
- LED11_Lightshow
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 5e02d10d8d58 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Nov 21 20:01:49 2010 +0000 @@ -0,0 +1,58 @@ +#include "mbed.h" + +DigitalOut myleda(LED1); +DigitalOut myledb(LED2); +DigitalOut myledc(LED3); +DigitalOut myledd(LED4); + +int nDisplayTemp; +int i; +int nDisplay[100]={ // set number in array + 1000,0100,0010,0001,1000,0100,0010,0001,1000,0100, // 1: 0 - 09 light display + 0010,0001,1000,0100,0010,0001,0000,1111,0110,1001, // 2: 10 - 19 light display + 0110,1111,0000,0001,0010,0100,1000,0001,0010,0100, // 3: 20 - 29 light display + 1000,0001,0010,0100,1000,0001,0010,0100,1000,0000, // 4: 30 - 39 light display + 1111,0110,1001,0110,1001,0110,1111,0000,1000,1100, // 5: 40 - 49 light display + 1110,1111,0111,0011,0001,0000,0001,0011,0111,1111, // 6: 50 - 59 light display + 1110,1100,1000,0000,1111,1001,0110,1001,1111,1111, // 7: 60 - 69 light display + 0111,0011,0001,1000,1100,1110,1111,0000,1110,1101, // 8: 70 - 79 light display + 1011,0111,1110,1100,1000,0000,1111,1000,1100,1110, // 9: 80 - 89 light display + 1111,0111,1011,1101,1110,1111,0110,1101,1011,1111}; //10: 90 - 99 light display +int main() { + while (1){ + for (int i=0; i<100; i++) { // set i = array number + if (nDisplay[i]>=1000) // light no 1 : on or off + { myleda = 1; + nDisplayTemp = nDisplay[i] - 1000; + } + else + { myleda = 0; + nDisplayTemp = nDisplay[i]; + } + if (nDisplayTemp >= 0100) // light no 2 : on or off + { myledb = 1; + nDisplayTemp = nDisplayTemp - 0100; + } + else + { myledb = 0; + } + if (nDisplayTemp >= 0010) // light no 3 : on or off + { myledc = 1; + nDisplayTemp = nDisplayTemp - 0010; + } + else + { myledc = 0; + } + if (nDisplayTemp >= 0001) // light no 4 : on or off + { myledd = 1; + } + else + { myledd = 0; + } + + wait(0.2); + myleda = myledb = myledc = myledd = 0; // 0.2 sec : all lights off + wait(0.2); + } + } +}
diff -r 000000000000 -r 5e02d10d8d58 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Nov 21 20:01:49 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e