#include #include #include #ifdef __AVR__ #include // Required for 16 MHz Adafruit Trinket #endif //pin led data lead is connected to #define LED_PIN 13 // How many NeoPixels are attached to the Arduino? #define LED_COUNT 104 // Replace with your network credentials const char* ssid = "SCOTTCAMPUS"; const char* password = "mavericks"; // Define NTP Client to get time WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP); // Declare our NeoPixel strip object: Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); // Argument 1 = Number of pixels in NeoPixel strip // Argument 2 = Arduino pin number (most are valid) // Argument 3 = Pixel type flags, add together as needed: // Variables to save date and time String formattedDate; String dayStamp; String timeStamp; String hourStamp; String minuteStamp; uint32_t color = strip.Color(255,0,0); void setup() { // Initialize Serial Monitor Serial.begin(115200); Serial.print("Connecting to "); Serial.println(ssid); strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) colorWipe(strip.Color(0,0,0), 0); strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(100); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } // Print local IP address and start web server Serial.println(""); Serial.println("WiFi connected."); Serial.println("IP address: "); Serial.println(WiFi.localIP()); // Initialize a NTPClient to get time timeClient.begin(); // Set offset time in seconds to adjust for your timezone, for example: // GMT +1 = 3600 // GMT +8 = 28800 // GMT -1 = -3600 // GMT 0 = 0 timeClient.setTimeOffset(-18000); } void loop() { while(!timeClient.update()) { timeClient.forceUpdate(); } // The formattedDate comes with the following format: // 2018-05-28T16:00:13Z // We need to extract date and time formattedDate = timeClient.getFormattedDate(); // Extract date int splitT = formattedDate.indexOf("T"); dayStamp = formattedDate.substring(0, splitT); timeStamp = formattedDate.substring(splitT+1, formattedDate.length()-1); //Extract hour, minute int splitC = timeStamp.indexOf(":"); hourStamp = timeStamp.substring(0,splitC); minuteStamp = timeStamp.substring(splitC+1, timeStamp.length()-3); // Serial.println("Time: " + timeStamp); Serial.println("Hour: " + hourStamp); Serial.println("Minute: " + minuteStamp); colorWipe(strip.Color(0,0,0), 0); strip.show(); // Turn OFF all pixels ASAP showTime(hourStamp.toInt(),minuteStamp.toInt(),color); delay(300000); } // Fill strip pixels one after another with a color. Strip is NOT cleared // first; anything there will be covered pixel by pixel. Pass in color // (as a single 'packed' 32-bit value, which you can get by calling // strip.Color(red, green, blue) as shown in the loop() function above), // and a delay time (in milliseconds) between pixels. void colorWipe(uint32_t color, int wait) { for(int i=-1; i= 35) { hour++; } if(hour > 12) { hour = hour - 12; } strip.clear(); //Show "it is" SectionWrite(color,1,1,2); SectionWrite(color,1,4,5); //FIVE MINUTES if((minute >= 5) && (minute < 10) || (minute >= 55) && (minute <= 59)) { SectionWrite(color,1,27,30); SectionWrite(color,1,32,38); } //TEN MINUTES if((minute >= 10 && minute < 15) || (minute >= 50) && (minute < 55)) { SectionWrite(color,1,7,9); SectionWrite(color,1,32,38); } //QUARTER if((minute >= 15 && minute < 20) || (minute >= 45) && (minute < 50)) { SectionWrite(color,1,20,26); } //TWENTY MINUTES if((minute >= 20 && minute < 25) || (minute >= 40) && (minute < 45)) { SectionWrite(color,1,14,19); SectionWrite(color,1,32,38); } //TWENTY FIVE MINUTES if((minute >= 25 && minute < 30) || (minute >= 35) && (minute < 40)) { SectionWrite(color,1,14,19); SectionWrite(color,1,27,30); SectionWrite(color,1,32,38); } //HALF if(minute >= 30 && minute < 35) { SectionWrite(color,1,10,13); } //PAST if(minute >= 5 && minute < 35) { SectionWrite(color,1,49,52); } //TO if(minute >= 35) { SectionWrite(color,1,47,48); } //hours if(hour == 1) { SectionWrite(color,1,43,45); } else if(hour == 2) { SectionWrite(color,1,40,42); } else if(hour == 3) { SectionWrite(color,1,53,57); } else if(hour == 4) { SectionWrite(color,1,58,61); } else if(hour == 5) { SectionWrite(color,1,62,65); } else if(hour == 6) { SectionWrite(color,1,76,78); } else if(hour == 7) { SectionWrite(color,1,71,75); } else if(hour == 8) { SectionWrite(color,1,66,70); } else if(hour == 9) { SectionWrite(color,1,79,82); } else if(hour == 10) { SectionWrite(color,1,83,85); } else if(hour == 11) { SectionWrite(color,1,86,91); } else if(hour == 12 | hour == 0) { SectionWrite(color,1,99,104); } //O CLOCK if((minute >= 0) && (minute < 5)) { SectionWrite(color,1,92,97); } }