Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_NeoPixel.h>
- #include <RTClib.h>
- #include <Wire.h>
- RTC_DS3231 rtc;
- #define PIN 10
- #define NUM_LEDS 14
- #define BRIGHTNESS 60
- long mHour;
- long mMinute;
- Adafruit_NeoPixel stripHour = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800);
- Adafruit_NeoPixel stripMin = Adafruit_NeoPixel(20, 9, NEO_GRBW + NEO_KHZ800);
- int colorSet;
- void setup() {
- delay(3000); //power-up safety delay
- stripHour.setBrightness(BRIGHTNESS);
- stripHour.begin();
- stripHour.show();
- stripMin.setBrightness(BRIGHTNESS);
- stripMin.begin();
- stripMin.show();
- // Serial.begin(57600);
- if (! rtc.begin()) {
- Serial.println("Couldn't find RTC");
- while (1);
- }
- //sets date and time
- rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
- }
- void loop() {
- DateTime now = rtc.now();
- //Prints Time
- Serial.print(now.hour(), DEC);
- Serial.print(':');
- Serial.print(now.minute(), DEC);
- Serial.print(':');
- Serial.print(now.second(), DEC);
- Serial.println();
- delay(1000);
- //Controlling the hour and minute
- mHour = now.hour();
- mMinute = now.minute();
- if (mHour == 0) {
- breathe(stripHour.Color(25, 25, 112), 60);//Darker Blue
- Serial.print("Hello");
- }
- if (mHour == 1) {
- breathe(stripHour.Color(136, 206, 250), 60);//Sky Blue
- }
- if (mHour == 2) {
- minColor();
- //whiteOverRainbow(20,75,5);
- breathe(stripHour.Color(175, 238, 238), 60);//Light blue
- Serial.print("Hello");
- }
- if (mHour == 3) {
- breathe(stripHour.Color(221, 160, 221), 60);//Pink
- }
- if (mHour == 4) {
- breathe(stripHour.Color(123, 104, 238), 60);//Purple
- }
- if (mHour == 5) {
- breathe(stripHour.Color(75, 0, 130), 60);//Violet
- }
- if (mHour == 6) {
- breathe(stripHour.Color(153, 50, 204), 60);//Light Purple
- }
- if (mHour == 7) {
- breathe(stripHour.Color(238, 130, 238), 60);//Light Pink
- }
- if (mHour == 8) {
- breathe(stripHour.Color(255, 215, 0), 60);//Light Orange
- }
- if (mHour == 9) {
- breathe(stripHour.Color(255, 140, 0), 60);//Orange
- }
- if (mHour == 10) {
- breathe(stripHour.Color(160, 80, 0), 60);// Light Red
- }
- if (mHour == 11) {
- breathe(stripHour.Color(255, 0, 0), 60);//Red
- }
- if (mHour == 12) {
- breathe(stripHour.Color(178, 34, 34), 60);//Dark Red
- }
- if (mHour == 13) {
- breathe(stripHour.Color(210, 105, 30), 60);//Red Orange
- }
- if (mHour == 14) {
- breathe(stripHour.Color(245, 222, 179), 60);//Light Brown
- }
- if (mHour == 15) {
- breathe(stripHour.Color(173, 255, 47), 60);//Bright Green
- }
- if (mHour == 16) {
- breathe(stripHour.Color(0, 255, 154), 60);// Bright Yellow Green
- }
- if (mHour == 17) {
- breathe(stripHour.Color(154, 205, 50), 60);//Light Green
- }
- if (mHour == 18) {
- breathe(stripHour.Color(0, 255, 0), 60);//Green
- }
- if (mHour == 19) {
- breathe(stripHour.Color(0, 100, 0), 60);//Dark Green
- }
- if (mHour == 20) {
- breathe(stripHour.Color(0, 0, 139), 60);//Navy Blue
- }
- if (mHour == 21) {
- breathe(stripHour.Color(119, 136, 153), 60);// Blue Grey
- }
- if (mHour == 22) {
- breathe(stripHour.Color(25, 25, 112), 60);//Violet Blue
- }
- if (mHour == 23) {
- breathe(stripHour.Color(0, 0, 255), 60);//Blue
- }
- }
- void breathe(uint32_t c, uint8_t wait) {
- // Make the lights breathe
- for (int i = 0; i < 1200; i++) {
- // Intensity will go from 10 - MaximumBrightness in a "breathing" manner
- float intensity = 100 /2.0 * (1.0 + sin(0.008 * i));
- stripHour.setBrightness(intensity);
- // Now set every LED to that color
- for(uint16_t i=0; i<stripHour.numPixels(); i++) {
- stripHour.setPixelColor(i, c);
- }
- Serial.println("loop here");
- stripHour.show();
- //Wait a bit before continuing to breathe
- delay(5);
- }
- Serial.println("did it make it");
- }
- // Fill the dots one after the other with a color
- void colorWipe(uint32_t c, uint8_t wait) {
- for(uint16_t i=0; i<stripHour.numPixels(); i++) {
- stripHour.setPixelColor(i, c);
- stripHour.show();
- delay(wait);
- }
- }
- void fadeColor() {
- for (int i=50; i <200; i++) {
- stripHour.setBrightness(i);
- stripHour.show();
- delay(1);
- }
- for (int i=200; i>50; i++) {
- stripHour.setBrightness(i);
- }
- }
- void minColor() {
- DateTime now = rtc.now();
- mMinute = now.minute();
- if (mMinute == 30){
- Twinkle(0xff, 0, 0, 10, 100, false);
- Serial.println("minute twinkle");
- }
- else {
- breathe(stripMin.Color(0, 255, 0), 60);
- Serial.println("minute breathe");
- }
- }
- void Twinkle(byte red, byte green, byte blue, int Count, int SpeedDelay, boolean OnlyOne) {
- stripHour.Color(0,0,0);
- for (int i=0; i<Count; i++) {
- stripHour.setPixelColor(random(NUM_LEDS),red,green,blue);
- stripHour.show();
- delay(SpeedDelay);
- if(OnlyOne) {
- stripHour.Color(0,0,0);
- }
- }
- delay(SpeedDelay);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement