#include #include "RTClib.h" #include "math.h" #include #include RTC_DS3231 rtc; char daysOfTheWeek[7][12] = {"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jum'at", "Sabtu"}; /* Put your SSID & Password */ const char* ssid = "NodeMCU"; // Enter SSID here const char* password = "12345678"; //Enter Password here IPAddress local_ip(192,168,1,1); IPAddress gateway(192,168,1,1); IPAddress subnet(255,255,255,0); ESP8266WebServer server(80); #include #ifdef __AVR__ #include // Required for 16 MHz Adafruit Trinket #endif #define LED_PIN 2 // How many NeoPixels are attached to the Arduino? #define LED_COUNT 30 bool isNormal = true; int modes = 0; Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); void setup () { Serial.begin(9600); WiFi.softAP(ssid, password); WiFi.softAPConfig(local_ip, gateway, subnet); delay(100); #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif delay(3000); if (! rtc.begin()) { Serial.println("RTC tidak terbaca"); while (1); } if (rtc.lostPower()) { //atur waktu sesuai waktu pada komputer rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); //atur waktu secara manual // January 21, 2019 jam 10:30:00 // rtc.adjust(DateTime(2019, 1, 25, 10, 30, 0)); } strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255) server.on("/", handle_OnConnect); server.on("/normal", normal); server.on("/rainbow", rainbowreq); server.begin(); } void loop () { if(isNormal){ DateTime now = rtc.now(); server.handleClient(); strip.clear(); if(now.second()%2 == 1){ strip.setBrightness(50); strip.setPixelColor((now.second()/2 + 3) % 30, strip.Color(255/4, 0, 0)); strip.setPixelColor((now.second()/2+4) % 30, strip.Color(255/4, 0, 0)); }else{ strip.setBrightness(100); strip.setPixelColor((now.second()/2+3)%30, strip.Color(255, 0, 0)); } uint32_t color = strip.gamma32(strip.ColorHSV(65536 * 39 /360)); if(now.minute()%2 == 1){ strip.setBrightness(50); strip.setPixelColor((now.minute()/2 + 3) % 30, color); strip.setPixelColor(((now.minute()/2+1) + 3) % 30, color); }else{ strip.setBrightness(100); strip.setPixelColor((now.minute()/2 + 3) % 30, color); } color = strip.gamma32(strip.ColorHSV(65536 * 156 /360)); strip.setBrightness(100); int hourk = (now.hour() % 12)*2.5+3; strip.setPixelColor((hourk)%30, color); Serial.println(round((now.hour() % 12)*1.25)); strip.show(); delay(200); }else{ rainbow(10); delay(2000); } } void colorWipe(uint32_t color, int wait) { for(int i=0; i RGB strip.setPixelColor(c, color); // Set pixel 'c' to value 'color' } strip.show(); // Update strip with new contents delay(wait); // Pause for a moment firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames } } } //Instruksi untuk Menampilkan Data RTC pada LCD