Example program using the mbed 23 LEDs prototype shield. The shield has 23 LEDs attached to D0-D15, A0-A5, plus one for power indication.
Dependencies: mbed
Revision 5:b760013d9d08, committed 2016-10-06
- Comitter:
- screamer
- Date:
- Thu Oct 06 19:23:24 2016 +0100
- Parent:
- 4:067032ed9bd3
- Commit message:
- Improved test LED patterns
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 067032ed9bd3 -r b760013d9d08 main.cpp --- a/main.cpp Fri Feb 13 09:45:19 2015 +0000 +++ b/main.cpp Thu Oct 06 19:23:24 2016 +0100 @@ -20,13 +20,38 @@ BusOut bus1(D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15); BusOut bus2(A5, A4, A3, A2, A1, A0); -int i; +int i, j, l = 15, c = 3, r = 6; +float s = 0.1; int main() { - for (i=0; i<=65535; i++) { - bus1 = i; - bus2 = i; - wait(0.001); + bus1 = bus2 = 0; + for (i=0; i<=l; i++) { + bus1 = bus1 + (1 << i | 1 << i+1 | 1 << i+2); + bus2 = bus2 + (1 << i | 1 << i+1 | 1 << i+2); + wait(s); + i=i+2; + } + + bus1 = bus2 = 0; + for (j=0; j<c; j++) { + for (i=0; i<=l; i++) { + bus1 = bus1 + (1 << i+j); + bus2 = bus2 + (1 << i+j); + wait(s); + i=i+2; + } + } + + bus1 = bus2 = 0; + for (i=0; i<=l; i++) { + bus1 = bus1 + (1 << i); + bus2 = bus2 + (1 << i); + wait(s); + } + for (i=0; i<=l; i++) { + bus1 = bus1 - (1 << i); + bus2 = bus2 - (1 << i); + wait(s); } } \ No newline at end of file