Binary counter from 0 to (2^25)-1 with wraparound. Bits are displayed on the LED matrix, filling from bottom right. Press buttonA for a decimal representation of the current counter value.
Revision 0:f5e7d4075c2a, committed 2018-07-24
- Comitter:
- davidrainford
- Date:
- Tue Jul 24 14:28:18 2018 +0000
- Commit message:
- Binary counter from 0 to (2^25)-1 with wraparound. Bits are displayed on the LED matrix, filling from bottom right. Press buttonA for a decimal representation of the current counter value.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
microbit.lib | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jul 24 14:28:18 2018 +0000 @@ -0,0 +1,20 @@ +#include "MicroBit.h" + +MicroBit uBit; + +int main() +{ + char col[25] = {4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0}; + char row[25] = {4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}; + int i, count = 0; + uBit.init(); + while (1) { + for (i = 0; i < 25; i++) { + uBit.display.image.setPixelValue(col[i], row[i], ((count >> i) & 1) * 255); + } + if (uBit.buttonA.isPressed()) { + uBit.display.scroll(count); + } + count = count++ & 33554431; + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/microbit.lib Tue Jul 24 14:28:18 2018 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/Lancaster-University/code/microbit/#4b89e7e3494f