Make an 8x8 Matrix (HT16K33) Light Up Random Diodes

Hello everyone! I am trying to make an 8x8 single color matrix, (Red) connected to a HT16K33 Backpack, light up random diodes (and turn random diodes off) in quick succession. I am using an Arduino Uno and the Adafruit LED Backpack Library from Github. Also,Here is a video of what I am trying to Achieve. The user was very gracious and shared his code. The only issue I have is that he is using a Bi-Colored Matrix. The Matrix I am using is Single colored. Here is the code he used.

#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"

Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();

const int colors[3] = { LED_GREEN, LED_YELLOW, LED_RED };

int count = 0;

void setup() {
  Serial.begin(9600);
  Serial.println("8x8 LED Matrix Test");
  
  matrix.begin(0x70);  // pass in the address
  
  matrix.setBrightness(15);
  
  matrix.setRotation(3);
}

void loop() {
  matrix.clear();
    
  for(int x = 0; x < 8; x++) {
    for(int y = 0; y < 8; y++) {
      if(random(0,2) == 0) {
        matrix.drawPixel(y, x, colors[random(0,3)]);
      }
    }
  }

  matrix.writeDisplay();  

  delay(50);
}

This is the original code. I am unsure if this code could be tweaked to work with a single color matrix. Is it possible? I have not tried to use this code as is because I fear it may harm the matrix. Thanks for your Time everyone!

It won't harm the matrix. Try it.

Thank you so much for your reply! :smiley: The code worked in its base form! I would have never guessed it would! Thank you a Ton!

On the technical side, I always though that to create different colors, such as with the RBG colored matrix different voltages were applied to the diodes to change the hue does that not apply here because the bi-colored matrix has two separate diodes that are addressed and cannot be changed color wise? I just want to understand!!! :o

Once again, Thank you very much.