/*
8x8 NeoPixel WiFi Clock
ESP32 + WS2812B 64 LED Matrix
Libraries Required:
- Adafruit NeoPixel
- WiFi.h
- NTPClient
- WiFiUdp
*/
#include <WiFi.h>
#include <WiFiUdp.h>
#include <NTPClient.h>
#include <Adafruit_NeoPixel.h>
#define LED_PIN 6
#define LED_COUNT 64 // 8x8 matrix
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// ====== WiFi Credentials ======
const char* ssid = "YAirtel_arv_6035";
const char* password = "air28269";
// ====== NTP Setup ======
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", 19800, 60000);
// 19800 = IST offset in seconds (UTC+5:30)
void setup() {
strip.begin();
strip.setBrightness(80);
strip.show();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
timeClient.begin();
}
void loop() {
timeClient.update();
int hours = timeClient.getHours();
int minutes = timeClient.getMinutes();
int seconds = timeClient.getSeconds();
// Clear matrix
strip.clear();
// Display HH:MM (basic demo: show digits as blocks)
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 ======
// Each digit is drawn as a vertical bar on the matrix.
// For a real clock, replace with proper 5x7 font mapping.
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 ======
// Converts (row,col) to LED index depending on wiring (serpentine assumed)
int matrixIndex(int row, int col) {
if (row % 2 == 0) {
return row * 8 + col;
} else {
return row * 8 + (7 - col);
}
}
Loading
xiao-esp32-c3
xiao-esp32-c3
FPS: 0
Power: 0.00W
Power: 0.00W
https://wokwi.com/projects/468264906400489473
AI CENTRE NANDURBAR