#include <FastLED.h>
#include <WiFi.h>
#include <sntp.h>
#define LED_PIN 4
#define NUM_LEDS 12
#define LED_ORDER GRB
#define LED_TYPE WS2812B
CRGB leds[NUM_LEDS];
void setup(){
FastLED.addLeds<LED_TYPE, LED_PIN, LED_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(128);
Serial.begin(115200);
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
}
configTime(0,0,"pool.ntp.org");
setenv("TZ","MYT-8",1); //your timezone
tzset();
}
void loop(){
FastLED.clear();
time_t now = time(NULL);
struct tm *tm = localtime(&now);
int new_hour;
if(tm->tm_hour > 12){
new_hour = tm->tm_hour - 12;
} else {
new_hour = tm->tm_hour;
}
leds[map(new_hour, 0, 12, 0, NUM_LEDS)] = CRGB::Blue;
leds[map(tm->tm_sec, 0, 60, 0, NUM_LEDS)] = CRGB::Red;
leds[map(tm->tm_min, 0, 60, 0, NUM_LEDS)] = CRGB::Green;
FastLED.show();
delay(500);
}