Arnov Sharma
Published © MIT

64x32 Matrix Panel Setup with PICO 2

Setting up the 64x32 RGB matrix panel using PICO 2 as the main controller board.

BeginnerFull instructions provided1 hour209
64x32 Matrix Panel Setup with PICO 2

Things used in this project

Hardware components

Raspberry Pi Pico
Raspberry Pi Pico
×1
PCBWay Matrix 64x32
×1
PCBWay Custom PCB
PCBWay Custom PCB
×1

Software apps and online services

Fusion
Autodesk Fusion
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Frame

cad file

Schematics

WIRING

Code

TEST 01

C/C++
#include <Adafruit_Protomatter.h>

// Pin definitions
#define R1 2
#define G1 3
#define B1 4
#define R2 5
#define G2 8
#define B2 9
#define A 10
#define B 16
#define C 18
#define D 20
#define CLK 11
#define LAT 12
#define OE 13

#define WIDTH 64
#define HEIGHT 32

uint8_t rgbPins[] = { R1, G1, B1, R2, G2, B2 };
uint8_t addrPins[] = { A, B, C, D };

Adafruit_Protomatter matrix(WIDTH, HEIGHT, 1, rgbPins, 4, addrPins, CLK, LAT, OE, false);

void setup() {
  matrix.begin();
  
  // Test: Fill screen with red
  matrix.fillScreen(matrix.color565(255, 0, 0));
  matrix.show();
  delay(500);
  
  // Test: Fill screen with green
  matrix.fillScreen(matrix.color565(0, 255, 0));
  matrix.show();
  delay(500);
  
  // Test: Fill screen with blue
  matrix.fillScreen(matrix.color565(0, 0, 255));
  matrix.show();
  delay(500);
}

void loop() {
  // Test: Horizontal rainbow gradient
  for (int x = 0; x < WIDTH; x++) {
    uint16_t color = matrix.color565(x * 4, 255 - (x * 4), 128); // Gradient colors
    matrix.drawFastVLine(x, 0, HEIGHT, color);
  }
  matrix.show();
  delay(1000);
  
  // Test: Vertical rainbow gradient
  for (int y = 0; y < HEIGHT; y++) {
    uint16_t color = matrix.color565(255 - (y * 8), y * 8, 128); // Gradient colors
    matrix.drawFastHLine(0, y, WIDTH, color);
  }
  matrix.show();
  delay(1000);
  
  // Test: Diagonal lines
  for (int i = 0; i < WIDTH; i += 4) {
    uint16_t color = matrix.color565(255 - (i * 4), i * 4, 255 - (i * 2)); // Gradient colors
    matrix.drawLine(0, i, WIDTH - 1, HEIGHT - 1 - i, color);
    matrix.drawLine(i, 0, WIDTH - 1 - i, HEIGHT - 1, color);
  }
  matrix.show();
  delay(1000);
  
  // Test: Moving box
  for (int i = 0; i < WIDTH - 10; i += 1) {
    matrix.fillScreen(0); // Clear screen
    matrix.drawRect(i, HEIGHT / 2 - 5, 10, 10, matrix.color565(255, 255, 0)); // Yellow box
    matrix.show();
    delay(50);
  }
}

GAME OF LIFE

C/C++
#include <Adafruit_Protomatter.h>

// Pin definitions
#define R1 2
#define G1 3
#define B1 4
#define R2 5
#define G2 8
#define B2 9
#define A 10
#define B 16
#define C 18
#define D 20
#define CLK 11
#define LAT 12
#define OE 13

#define WIDTH 64
#define HEIGHT 32

uint8_t rgbPins[] = { R1, G1, B1, R2, G2, B2 };
uint8_t addrPins[] = { A, B, C, D };
Adafruit_Protomatter matrix(WIDTH, HEIGHT, 1, rgbPins, 4, addrPins, CLK, LAT, OE, false);

bool grid[WIDTH][HEIGHT];
bool newGrid[WIDTH][HEIGHT];

void setup() {
  matrix.begin();
  randomSeed(analogRead(0));

  // Initialize grid with random values
  for(int x = 0; x < WIDTH; x++) {
    for(int y = 0; y < HEIGHT; y++) {
      grid[x][y] = random(2);
    }
  }
}

void loop() {
  matrix.fillScreen(0);

  // Update grid based on Game of Life rules
  for(int x = 0; x < WIDTH; x++) {
    for(int y = 0; y < HEIGHT; y++) {
      int aliveNeighbors = countAliveNeighbors(x, y);
      
      if(grid[x][y]) {
        // Any live cell with two or three live neighbors survives.
        if(aliveNeighbors < 2 || aliveNeighbors > 3) {
          newGrid[x][y] = false;
        } else {
          newGrid[x][y] = true;
        }
      } else {
        // Any dead cell with three live neighbors becomes a live cell.
        if(aliveNeighbors == 3) {
          newGrid[x][y] = true;
        } else {
          newGrid[x][y] = false;
        }
      }
      
      if(newGrid[x][y]) {
        matrix.drawPixel(x, y, matrix.color565(255, 255, 255)); // White color
      }
    }
  }

  // Copy newGrid to grid
  memcpy(grid, newGrid, sizeof(grid));
  
  matrix.show();
  delay(100); // Adjust the delay for speed control

  // Check if the grid is stable or empty
  if(isGridStableOrEmpty()) {
    resetGrid();
  }
}

int countAliveNeighbors(int x, int y) {
  int aliveNeighbors = 0;
  for(int dx = -1; dx <= 1; dx++) {
    for(int dy = -1; dy <= 1; dy++) {
      if(dx == 0 && dy == 0) continue;
      int nx = (x + dx + WIDTH) % WIDTH;
      int ny = (y + dy + HEIGHT) % HEIGHT;
      if(grid[nx][ny]) {
        aliveNeighbors++;
      }
    }
  }
  return aliveNeighbors;
}

bool isGridStableOrEmpty() {
  for(int x = 0; x < WIDTH; x++) {
    for(int y = 0; y < HEIGHT; y++) {
      if(grid[x][y]) {
        return false;
      }
    }
  }
  return true;
}

void resetGrid() {
  for(int x = 0; x < WIDTH; x++) {
    for(int y = 0; y < HEIGHT; y++) {
      grid[x][y] = random(2);
    }
  }
}

Credits

Arnov Sharma
339 projects • 345 followers
Just your average MAKER
Contact

Comments

Please log in or sign up to comment.