Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Date and time functions using a DS1307 RTC connected via I2C and Wire lib
- #include <Wire.h>
- #include <SPI.h> // not used here, but needed to prevent a RTClib compile error
- #include <RTClib.h>
- #include <Adafruit_NeoPixel.h>
- #define PIN 6
- Adafruit_NeoPixel stripHour = Adafruit_NeoPixel(24, PIN, NEO_GRB + NEO_KHZ800);
- RTC_DS3231 RTC;
- long mHour;
- void setup () {
- stripHour.begin();
- stripHour.show(); // Initialize all pixels to 'off'
- Serial.begin(57600);
- Wire.begin();
- RTC.begin();
- if (! RTC.isrunning()) {
- Serial.println("RTC is NOT running!");
- // following line sets the RTC to the date & time this sketch was compiled
- RTC.adjust(DateTime(__DATE__, __TIME__));
- }
- }
- /******************************
- Main Loop
- *******************************/
- 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();
- Serial.println();
- delay(1000);
- mHour = now.hour();// defining hour now
- long mn = now.minute();
- //Controlling the hour
- if (mHour == 0){
- hour_0();
- }
- if(mHour == 1){
- hour_1();
- }
- if(mHour == 2){
- hour_2();
- }
- if(mHour == 3){
- hour_3();
- }
- if(mHour == 4){
- hour_4();
- }
- if(mHour == 5){
- hour_5();
- }
- if(mHour == 6){
- hour_6();
- }
- if(mHour == 7){
- hour_7();
- }
- if(mHour == 8){
- hour_8();
- }
- if(mHour == 9){
- hour_9();
- }
- if(mHour == 10){
- hour_10();
- }
- if(mHour == 11){
- hour_11();
- }
- if(mHour == 12){
- hour_12();
- }
- if(mHour == 13){
- hour_13;
- }
- if(mHour == 14){
- hour_14();
- }
- if(mHour == 15){
- hour_15();
- }
- if(mHour == 16){
- hour_16();
- }
- if(mHour == 17){
- hour_17();
- }
- if(mHour == 18){
- hour_18();
- }
- if(mHour == 19){
- hour_19();
- }
- if(mHour == 20){
- hour_20();
- }
- if(mHour == 21){
- hour_21();
- }
- if(mHour == 22){
- hour_22();
- }
- if (mHour == 23){
- hour_23();
- }
- }
- /******************************
- Fade
- *******************************/
- void fade(){
- }
- /******************************
- Color Wipe
- *******************************/
- //Fills Neopixil
- 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);
- }
- }
- /******************************
- Set Color
- *******************************/
- // functions for the colors of each hour
- void hour_0(){
- colorWipe(stripHour.Color(25, 25, 112), 50); //Darker Blue
- }
- void hour_1(){
- colorWipe(stripHour.Color(136, 206, 250), 50); //Sky Blue
- }
- void hour_2(){
- colorWipe(stripHour.Color(175, 238, 238), 50); //Light Blue
- }
- void hour_3(){
- colorWipe(stripHour.Color(221, 160, 221), 50); //Pink
- }
- void hour_4(){
- colorWipe(stripHour.Color(123, 104, 238), 50); //Purple
- }
- void hour_5(){
- colorWipe(stripHour.Color(75, 0, 130), 50); //Violet
- }
- void hour_6(){
- colorWipe(stripHour.Color(153, 50, 204), 50); //Light Purple
- }
- void hour_7(){
- colorWipe(stripHour.Color(238, 130, 238), 50); //Light Pink
- }
- void hour_8(){
- colorWipe(stripHour.Color(255, 215, 0), 50); //Light Oragne
- }
- void hour_9(){
- colorWipe(stripHour.Color(255, 140, 0), 50); //Orange
- }
- void hour_10(){
- colorWipe(stripHour.Color(160, 80, 0), 50); // Light Red
- }
- void hour_11(){
- colorWipe(stripHour.Color(255, 0, 0), 50); //Red
- }
- void hour_12(){
- colorWipe(stripHour.Color(178, 34, 34), 50); //Dark Red
- }
- void hour_13(){
- colorWipe(stripHour.Color(210, 105, 30), 50); //Red Orange
- }
- void hour_14(){
- colorWipe(stripHour.Color(245, 222, 179), 50); //Light Brown
- }
- void hour_15(){
- colorWipe(stripHour.Color(173, 255, 47), 50); //Bright Green
- }
- void hour_16(){
- colorWipe(stripHour.Color(0, 255, 154), 50); //Bright Yellow Green
- }
- void hour_17(){
- colorWipe(stripHour.Color(154, 205, 50), 50); //Light Green
- }
- void hour_18(){
- colorWipe(stripHour.Color(0, 255, 0), 50); //Green
- }
- void hour_19(){
- colorWipe(stripHour.Color(0, 100, 0), 50); //Dark Green
- }
- void hour_20(){
- colorWipe(stripHour.Color(0, 0, 139), 50); //Navy Blue
- }
- void hour_21(){
- colorWipe(stripHour.Color(119, 136, 153), 50); //Blue Grey
- }
- void hour_22(){
- colorWipe(stripHour.Color(25, 25, 112), 50); //Violet Blue
- }
- void hour_23(){
- colorWipe(stripHour.Color(0, 0, 255), 50); //Blue
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement