//
// ESP32 NeoPixel 32x32 Panel Demo - this demo uses four 8x32 panels
// to create a single 32x32 maxtrix.
//
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define PIN 2
// Four panel matrix
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, 1, 4, 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);
// Other declarations
const int displayWidth = matrix.width();
const int displayHeight = matrix.height();
const uint16_t red = matrix.Color(255, 0, 0);
const uint16_t green = matrix.Color(0, 255, 0);
const uint16_t blue = matrix.Color(0, 0, 255);
const uint16_t yellow = matrix.Color(255, 255, 0);
const uint16_t magenta = matrix.Color(255, 0, 2550);
const uint16_t black = matrix.Color(0, 0, 0);
//
// Setup function
//
void setup() {
matrix.begin();
matrix.setBrightness(255);
Serial.begin(115200);
Serial.print("The matrix panel is ");
Serial.print(displayWidth);
Serial.print(" pixels wide and ");
Serial.print(displayHeight);
Serial.println(" pixels high.");
}
//
// Loop function
//
void loop() {
showIndividualPixels();
delay(2000);
showPixelsByRow();
delay(2000);
fillPanel(magenta);
delay(2000);
matrix.clear();
matrix.show();
delay(1000);
}
void fillPanel(uint16_t fillColor) {
matrix.clear();
matrix.fillScreen(fillColor);
matrix.show();
}
void showIndividualPixels() {
matrix.clear();
// Set individual pixels in the pixel RAM to specific colors using row and column coordinates
matrix.drawPixel(0,0,matrix.Color(255,255,0)); // set to yellow
matrix.drawPixel(0,7,matrix.Color(255,0,0)); // set to red
matrix.drawPixel(0,31,matrix.Color(0,255,0)); // set to green
matrix.drawPixel(8,1,matrix.Color(0,0,255)); // set to blue
matrix.drawPixel(15,31,matrix.Color(255,166,0)); // set to orange
matrix.drawPixel(16,10,matrix.Color(0,255,255)); // set to aqua
matrix.drawPixel(31,29,matrix.Color(255,0,255)); // set to magenta
matrix.show();
}
void showPixelsByRow() {
for (int y=0; y<=31; y++) {
Serial.print("Showing row ");
Serial.print(y);
Serial.println(" ...");
for (int x=0; x<=31; x++) {
matrix.drawPixel(x,y,matrix.Color(255,255,0));
matrix.show();
delay(5);
}
}
}
X Coordinate -->
Y Coordinate -->