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.
Diff: main.cpp
- Revision:
- 0:f5e7d4075c2a
diff -r 000000000000 -r f5e7d4075c2a main.cpp --- /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