Arnov Sharma
Published © MIT

Happy Week Indicator

A PCB setup with serotonin graphics and a NeoPixel LED that glows red on weekdays and green on weekends.

BeginnerFull instructions provided1 hour524
Happy Week Indicator

Things used in this project

Hardware components

XIAO ESP32C3
Seeed Studio XIAO ESP32C3
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Seeed Studio Fusion PCB/PCBA
Seeed Studio Fusion PCB/PCBA

Story

Read more

Schematics

SCH

Code

code

C/C++
#include <WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <Adafruit_NeoPixel.h>
#define LED_PIN D0 // GPIO pin connected to the NeoPixel
#define NUM_LEDS 16 // Number of NeoPixels
// WiFi credentials
const char* ssid = "UR SSID";
const char* password = "UR PASS";
// Define NeoPixel strip object
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
// Define NTP Client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", 19800, 60000); // IST timezone offset (19800 seconds)
unsigned long lastChange = 0;
bool isWeekend = false;
// Function to connect to Wi-Fi
void connectToWiFi() {
Serial.print("Connecting to WiFi...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED && millis() < 20000) { // Limit connection attempt to 20 seconds
delay(500);
Serial.print(".");
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println("Connected to WiFi");
} else {
Serial.println("Failed to connect to WiFi");
}
}
void setup() {
Serial.begin(115200);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
connectToWiFi();
timeClient.begin();
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
timeClient.update();
int dayOfWeek = timeClient.getDay();
isWeekend = (dayOfWeek == 0 || dayOfWeek == 6);
} else {
// Default behavior to alternate colors if not connected to Wi-Fi
if (millis() - lastChange > 10000) { // Change color every 10 seconds
isWeekend = !isWeekend;
lastChange = millis();
}
}
if (isWeekend) {
strip.fill(strip.Color(0, 255, 0), 0, NUM_LEDS); // Green for weekends
} else {
strip.fill(strip.Color(255, 0, 0), 0, NUM_LEDS); // Red for weekdays
}
strip.show();
delay(1000); // Update every second
}

Credits

Arnov Sharma
352 projects • 360 followers
I'm Arnov. I build, design, and experiment with tech—3D printing, PCB design, and retro consoles are my jam.

Comments