/*
8x8 NeoPixel RTC Clock
Arduino Nano + DS3231 + WS2812B 64 LED Matrix
Libraries Required:
- Adafruit NeoPixel
- RTClib (by Adafruit)
*/
#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_NeoPixel.h>
#define LED_PIN D10
#define LED_COUNT 64 // 8x8 matrix
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
RTC_DS3231 rtc;
// =======================================================
void setup() {
strip.begin();
strip.setBrightness(80);
strip.show();
if (!rtc.begin()) {
while (1); // hang if RTC not found
}
// Uncomment once to set RTC time to compile time
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
// =======================================================
void loop() {
DateTime now = rtc.now();
int hours = now.hour();
int minutes = now.minute();
int seconds = now.second();
strip.clear();
// Display HH:MM on matrix
displayDigit(hours / 10, 0); // tens of hour
displayDigit(hours % 10, 2); // ones of hour
displayDigit(minutes / 10, 5); // tens of minute
displayDigit(minutes % 10, 7); // ones of minute
strip.show();
delay(1000);
}
// =======================================================
// Digit Display (simple bar demo)
// =======================================================
void displayDigit(int num, int col) {
uint32_t color = strip.Color(0, 150, 255);
for (int row = 0; row < 8; row++) {
int idx = matrixIndex(row, col);
if (row < num) {
strip.setPixelColor(idx, color);
}
}
}
// =======================================================
// Matrix Mapping (serpentine wiring assumed)
// =======================================================
int matrixIndex(int row, int col) {
if (row % 2 == 0) {
return row * 8 + col;
} else {
return row * 8 + (7 - col);
}
}
FPS: 0
Power: 0.00W
Power: 0.00W
https://wokwi.com/projects/468264906400489473
AI CENTRE NANDURBAR