//
// Demo using 4 NeoMatrix panels as a single LED panel.
//
// https://wokwi.com/projects/397888798172777473
//
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define PIN 8
int Delay = 1000;
Adafruit_NeoMatrix panel = Adafruit_NeoMatrix(8, 8, 2, 2, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE +
NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_ROWS + NEO_TILE_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
//
// Setup function
//
void setup() {
panel.begin();
panel.setBrightness(255);
}
//
// Define some colors
//
uint16_t red = panel.Color(255,0,0);
uint16_t green = panel.Color(0,255,0);
uint16_t blue = panel.Color(0,0,255);
uint16_t magenta = panel.Color(255, 0, 255);
//
// Loop function
//
void loop() {
// Set individual pixels to specific colors in the pixel RAM. Note that the
// this sequence treats the panel as an LED strip.
panel.setPixelColor(0,255,255,0); // Set pixel 0 to yellow
panel.setPixelColor(7,255,0,0); // Set pixel 7 to red
panel.setPixelColor(8,0,255,0); // Set pixel 8 to green
panel.setPixelColor(63,0,0,255); // Set pixel 63 to blue
panel.setPixelColor(64,0,255,255); // Set pixel 64 to aqua
panel.setPixelColor(127,255,0,255); // Set pixel 127 to magenta
panel.setPixelColor(254,255,166,0); // Set pixel 128 to orange
panel.setPixelColor(191,255,255,0); // Set pixel 191 to yellow
panel.setPixelColor(192,255,0,0); // Set pixel 192 to red
panel.setPixelColor(254,0,255,0); // Set pixel 254 to green
// Update the LED panel with the colors stored in the pixel RAM
panel.show();
delay(Delay);
// Set the pixels to a rainbow of colors and then update the LED panel.
// Again this sequence treats the LED panel as an LED strip.
panel.rainbow(0,1);
panel.show();
delay(Delay);
for (int i=0; i<=64; i++) {
panel.rainbow(1024*i,1);
panel.show();
delay(10);
}
delay(Delay);
// Clear the pixel RAM and then update the LED panel.
panel.clear();
panel.show();
delay(Delay);
// Now treat the LED panel as a single matrix using row and column coordinates rather
// than referencing individual pixels as with an LED strip
// Again set individual pixels in the pixel RAM to specific colors but
// this time, using x and y coordinates
panel.drawPixel(0,0,panel.Color(255,255,0)); // set to yellow
panel.drawPixel(7,0,panel.Color(255,0,0)); // set to red
panel.drawPixel(8,0,panel.Color(0,255,255)); // set to aqua
panel.drawPixel(0,1,panel.Color(0,255,0)); // set to green
panel.drawPixel(7,7,panel.Color(0,0,255)); // set to blue
panel.drawPixel(15,7,panel.Color(255,0,255)); // set to magenta
panel.drawPixel(8,8,panel.Color(255,0,0)); // set to red
panel.drawPixel(7,15,panel.Color(255,255,0)); // set to yellow
panel.drawPixel(14,15,panel.Color(0,255,0)); // set to green
// Update the LED panel with the colors stored in the pixel RAM
panel.show();
delay(Delay);
// Set all of the pixels in the panel to a magenta color
panel.fillScreen(magenta);
panel.show();
delay(Delay);
// Draw a 4x6 blue rectectangle at coordinate 1,1 in the LED panel and
// then move it around on the LED panel 3 times
for (int loop=1; loop<=2; loop++){
for (int i=1; i<=11; i++) {
panel.fillScreen(magenta);
panel.drawRect(i,1,4,6,blue);
panel.show();
delay(50);
}
for (int j=1; j<=9; j++) {
panel.fillScreen(magenta);
panel.drawRect(11,j,4,6,blue);
panel.show();
delay(50);
}
for (int i=11; i>=1; i--) {
panel.fillScreen(magenta);
panel.fillRect(i,9,4,6,blue);
panel.show();
delay(50);
}
for (int j=9; j>=1; j--) {
panel.fillScreen(magenta);
panel.fillRect(1,j,4,6,blue);
panel.show();
delay(50);
}
}
// while (true) {;}
// Rectangle on outside of entire board
panel.clear();
panel.drawRect(0,0,16,16,red);
panel.show();
delay(Delay);
// Fill in the rest of the board
panel.fillRect(1,1,14,14,green);
panel.show();
delay(Delay);
panel.clear();
panel.show();
delay(Delay);
// Draw a red circle with blue background
panel.fillScreen(blue);
panel.fillCircle(7,7,7,red);
panel.show();
delay(Delay);
// Triangle
panel.clear();
panel.drawTriangle(7,2,2,7,12,7,blue);
panel.show();
delay(Delay);
// Fill Triangle
panel.fillTriangle(7,13,2,8,12,8,red);
panel.show();
delay(Delay);
// Lines
panel.clear();
panel.drawLine(1,4,14,9,green);
panel.show();
delay(Delay);
panel.drawLine(4,2,9,13,magenta);
panel.show();
delay(Delay);
panel.clear();
}
X Coordinate -->
Y Coordinate -->