![](/media/cache/profiles/8e19a39c36b8e5e3afd2a3b2692aea96.50x50_q85.jpg)
User defined (4) LED changing display
main.cpp
- Committer:
- djgeenen
- Date:
- 2010-11-21
- Revision:
- 0:5e02d10d8d58
File content as of revision 0:5e02d10d8d58:
#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); } } }