// Matrix-style "digital rain" for the Arduino Uno Q's 13x8 blue LED matrix. // Frame-based animation: each loop builds an 8x13 pixel grid, packs it into the // uint32_t[4] the Arduino_LED_Matrix driver expects, and pushes it with // loadFrame(). The matrix is monochrome (pixels are on/off — no brightness), so // each column's drop is drawn as a lit head plus a short trailing segment. // // Uno Q matrix API is deliberately tiny: matrix.begin() + matrix.loadFrame(frame). // (No drawFrame/clear/setPixel — those do not exist here.) // // Compile: arduino-cli compile --fqbn arduino:zephyr:unoq --export-binaries // Flash: arduino-flash .ino.elf-zsk.bin (OpenOCD @ 0x80F0000) #include "Arduino_LED_Matrix.h" Arduino_LED_Matrix matrix; static const uint8_t W = 13; // columns static const uint8_t H = 8; // rows int8_t head[W]; // row of each column's leading drop (starts above the top) uint8_t len[W]; // length of the lit trail (head + tail) uint8_t period[W]; // loops between downward steps (per-column speed) uint8_t phase[W]; // step counter uint32_t frame[4]; void reseed(uint8_t x) { head[x] = -(int8_t)random(0, H); // stagger the start above the matrix len[x] = random(2, 5); // 2..4 lit pixels period[x] = random(1, 4); // 1 = fast, 3 = slow phase[x] = 0; } void setup() { matrix.begin(); randomSeed(micros()); for (uint8_t x = 0; x < W; x++) reseed(x); } void loop() { bool grid[H][W]; for (uint8_t y = 0; y < H; y++) for (uint8_t x = 0; x < W; x++) grid[y][x] = false; for (uint8_t x = 0; x < W; x++) { // draw the drop: head at head[x], tail extending upward for (uint8_t t = 0; t < len[x]; t++) { int y = head[x] - t; if (y >= 0 && y < H) grid[y][x] = true; } // advance this column on its own cadence if (++phase[x] >= period[x]) { phase[x] = 0; head[x]++; if (head[x] - (int8_t)len[x] >= (int8_t)H) reseed(x); // fully off the bottom } } // pack grid -> frame: row-major, MSB-first (pixel 0 = frame[0] bit 31) frame[0] = frame[1] = frame[2] = frame[3] = 0; uint16_t bit = 0; for (uint8_t y = 0; y < H; y++) for (uint8_t x = 0; x < W; x++) { if (grid[y][x]) frame[bit >> 5] |= (1UL << (31 - (bit & 31))); bit++; } matrix.loadFrame(frame); delay(90); }