#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define PIN 6 // Connect your matrix DIN to Arduino digital pin 6
// Configure a 32x8 NeoPixel Matrix
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE, // ✅ fixed
NEO_GRB + NEO_KHZ800);
// Timing configurations (in milliseconds)
const unsigned long PHASE_1_DURATION = 15000; // 15 seconds
const unsigned long PHASE_2_DURATION = 8000; // 8 seconds
// Animation Variables
int textX = 32;
unsigned long lastScrollTime = 0;
const int scrollSpeed = 60;
uint16_t randomColor;
uint16_t whiteColor = matrix.Color(255, 255, 255);
int currentPhase = 1;
unsigned long phaseStartTime = 0;
void setup() {
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(80); // brighter for testing
// Quick hardware test: cycle solid colors
matrix.fillScreen(matrix.Color(255, 0, 0)); matrix.show(); delay(1000);
matrix.fillScreen(matrix.Color(0, 255, 0)); matrix.show(); delay(1000);
matrix.fillScreen(matrix.Color(0, 0, 255)); matrix.show(); delay(1000);
matrix.fillScreen(0); matrix.show();
randomSeed(analogRead(0));
randomColor = matrix.Color(random(50, 256), random(50, 256), random(50, 256));
phaseStartTime = millis();
}
void loop() {
unsigned long currentTime = millis();
unsigned long elapsedInPhase = currentTime - phaseStartTime;
// Phase 1: AI CENTRE NANDURBAR
if (currentPhase == 1) {
if (elapsedInPhase >= PHASE_1_DURATION) {
currentPhase = 2;
phaseStartTime = currentTime;
matrix.fillScreen(0);
textX = 32;
} else {
scrollText("AI CENTRE NANDURBAR", randomColor);
}
}
// Phase 2: CODE BY ARVIND
else if (currentPhase == 2) {
if (elapsedInPhase >= PHASE_2_DURATION) {
currentPhase = 1;
phaseStartTime = currentTime;
matrix.fillScreen(0);
textX = 32;
randomColor = matrix.Color(random(50, 256), random(50, 256), random(50, 256));
} else {
scrollText("CODE BY ARVIND", whiteColor);
}
}
}
// --- HELPER FUNCTION ---
void scrollText(String text, uint16_t textColor) {
if (millis() - lastScrollTime > scrollSpeed) {
lastScrollTime = millis();
matrix.fillScreen(0);
matrix.setCursor(textX, 0);
matrix.setTextColor(textColor);
matrix.print(text);
matrix.show();
textX--;
// Accurate text width
int16_t x1, y1;
uint16_t w, h;
matrix.getTextBounds(text, textX, 0, &x1, &y1, &w, &h);
if (textX < -w) {
textX = 32;
}
}
}