Hi
My code is compiling but based on where I place the Countdown_Number () process the code stops there. All I am trying to do is get the day component of the time and date to work out the days till Christmas but it just gets to that part of the code and it stops. I have a feeling I am doing something very basic but doing it incorrectly and would appreciate any feedback.
Thanks
The code is below
//#include <Adafruit_NeoPixel.h>
#include <DS1307RTC.h>
#include <FastLED.h>
#include <Wire.h>
#include "RTClib.h"
#define DATA_PIN 7
#define NUM_LEDS 110
RTC_DS3231 rtc;
CRGB leds[NUM_LEDS];
const int Christmas_Day = 25;
int Display_Number ;
int Ten_Digit ;
int One_Digit ;
int loopcount;
long Flash_Start_Time;
long Flash_End_Time;
void setup() {
FastLED.addLeds<WS2811, DATA_PIN, BRG>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(255);
//Setting up DS3231
Serial.begin(9600);
delay(3000); // wait for console opening
One_Digit = (Display_Number / 1U) % 10;
}
void loop() {
// Flash_Start_Time = millis();
// Flash_End_Time = Flash_Start_Time;
// while ((Flash_End_Time - Flash_Start_Time) <=1000) // do this loop for up to 1000mS
//{
//TheaterChaseRainbow(50);
//loopcount = loopcount+1;
//Flash_End_Time = millis();
//}
// Clear_Screen();
//TheaterChaseRainbow(50);
Days_To_Display ();
Countdown_Number() ;
Star_Tree_Display();
Ten_Display();
One_Display();
}
void TheaterChaseRainbow(int SpeedDelay) {
byte *c;
for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q=0; q < 3; q++) {
for (int i=0; i < NUM_LEDS; i=i+3) {
c = Wheel( (i+j) % 255);
setPixel(i+q, *c, *(c+1), *(c+2)); //turn every third pixel on
}
showStrip();
delay(SpeedDelay);
for (int i=0; i < NUM_LEDS; i=i+3) {
setPixel(i+q, 0,0,0); //turn every third pixel off
}
}
}
}
byte * Wheel(byte WheelPos) {
static byte c[3];
if(WheelPos < 85) {
c[0]=WheelPos * 3;
c[1]=255 - WheelPos * 3;
c[2]=0;
} else if(WheelPos < 170) {
WheelPos -= 85;
c[0]=255 - WheelPos * 3;
c[1]=0;
c[2]=WheelPos * 3;
} else {
WheelPos -= 170;
c[0]=0;
c[1]=WheelPos * 3;
c[2]=255 - WheelPos * 3;
}
return c;
}
// *** REPLACE TO HERE ***
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
void Countdown_Number() {
DateTime now = rtc.now();
Display_Number = 0;
Display_Number = Christmas_Day - now.day();
Ten_Digit = (Display_Number / 10U) % 10;
One_Digit = (Display_Number / 1U) % 10;
}
void Clear_Screen() {
//..other setup stuff...
FastLED.clear(); // clear all pixel data
FastLED.show();
//startupLEDsTest(); // optional R,G,B test
//Serial.println("Setup done. \n");
} // end_setup
void Ten_Display () {
switch (Ten_Digit) {
case 0:
leds[0]= CRGB::Red;
leds[1]= CRGB::Red;
leds[2]= CRGB::Red;
leds[3]= CRGB::Red;
leds[4]= CRGB::Red;
leds[5]= CRGB::Red;
leds[6]= CRGB::Red;
leds[7]= CRGB::Red;
leds[8]= CRGB::Red;
leds[9]= CRGB::Red;
leds[10]= CRGB::Red;
leds[11]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
case 1:
leds[2]= CRGB::Red;
leds[3]= CRGB::Red;
leds[4]= CRGB::Red;
leds[5]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
}
}
void One_Display () {
switch (One_Digit) {
case 0:
leds[14]= CRGB::Red;
leds[15]= CRGB::Red;
leds[16]= CRGB::Red;
leds[17]= CRGB::Red;
leds[18]= CRGB::Red;
leds[19]= CRGB::Red;
leds[20]= CRGB::Red;
leds[21]= CRGB::Red;
leds[22]= CRGB::Red;
leds[23]= CRGB::Red;
leds[24]= CRGB::Red;
leds[25]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
case 1:
leds[16]= CRGB::Red;
leds[17]= CRGB::Red;
leds[18]= CRGB::Red;
leds[19]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
case 2:
leds[14]= CRGB::Red;
leds[15]= CRGB::Red;
leds[16]= CRGB::Red;
leds[17]= CRGB::Red;
leds[20]= CRGB::Red;
leds[21]= CRGB::Red;
leds[22]= CRGB::Red;
leds[23]= CRGB::Red;
leds[26]= CRGB::Red;
leds[27]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
case 3:
leds[14]= CRGB::Red;
leds[15]= CRGB::Red;
leds[16]= CRGB::Red;
leds[17]= CRGB::Red;
leds[18]= CRGB::Red;
leds[19]= CRGB::Red;
leds[20]= CRGB::Red;
leds[21]= CRGB::Red;
leds[26]= CRGB::Red;
leds[27]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
case 4:
leds[16]= CRGB::Red;
leds[17]= CRGB::Red;
leds[18]= CRGB::Red;
leds[19]= CRGB::Red;
leds[24]= CRGB::Red;
leds[25]= CRGB::Red;
leds[26]= CRGB::Red;
leds[27]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
case 5:
leds[14]= CRGB::Red;
leds[15]= CRGB::Red;
leds[18]= CRGB::Red;
leds[19]= CRGB::Red;
leds[20]= CRGB::Red;
leds[21]= CRGB::Red;
leds[24]= CRGB::Red;
leds[25]= CRGB::Red;
leds[26]= CRGB::Red;
leds[27]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
case 6:
leds[14]= CRGB::Red;
leds[15]= CRGB::Red;
leds[18]= CRGB::Red;
leds[19]= CRGB::Red;
leds[20]= CRGB::Red;
leds[21]= CRGB::Red;
leds[22]= CRGB::Red;
leds[23]= CRGB::Red;
leds[24]= CRGB::Red;
leds[25]= CRGB::Red;
leds[26]= CRGB::Red;
leds[27]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
case 7:
leds[14]= CRGB::Red;
leds[15]= CRGB::Red;
leds[16]= CRGB::Red;
leds[17]= CRGB::Red;
leds[18]= CRGB::Red;
leds[19]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
case 8:
leds[14]= CRGB::Red;
leds[15]= CRGB::Red;
leds[16]= CRGB::Red;
leds[17]= CRGB::Red;
leds[18]= CRGB::Red;
leds[19]= CRGB::Red;
leds[20]= CRGB::Red;
leds[21]= CRGB::Red;
leds[22]= CRGB::Red;
leds[23]= CRGB::Red;
leds[24]= CRGB::Red;
leds[25]= CRGB::Red;
leds[26]= CRGB::Red;
leds[27]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
case 9:
leds[14]= CRGB::Red;
leds[15]= CRGB::Red;
leds[16]= CRGB::Red;
leds[17]= CRGB::Red;
leds[18]= CRGB::Red;
leds[19]= CRGB::Red;
leds[20]= CRGB::Red;
leds[21]= CRGB::Red;
leds[24]= CRGB::Red;
leds[25]= CRGB::Red;
leds[26]= CRGB::Red;
leds[27]= CRGB::Red;
FastLED.show(); // apply the function on led strip
break;
}
}
void Days_To_Display () {
leds[28]= CRGB::Purple;
leds[29]= CRGB::Purple;
leds[30]= CRGB::Purple;
leds[31]= CRGB::Purple;
leds[32]= CRGB::Purple;
leds[33]= CRGB::Purple;
leds[34]= CRGB::Purple;
leds[35]= CRGB::Purple;
leds[36]= CRGB::Purple;
leds[37]= CRGB::Purple;
leds[38]= CRGB::Purple;
leds[39]= CRGB::Purple;
leds[40]= CRGB::Purple;
leds[41]= CRGB::Purple;
leds[42]= CRGB::Purple;
leds[43]= CRGB::Purple;
leds[44]= CRGB::Purple;
leds[45]= CRGB::Purple;
leds[46]= CRGB::Purple;
leds[47]= CRGB::Purple;
leds[48]= CRGB::Purple;
leds[49]= CRGB::Purple;
leds[50]= CRGB::Purple;
leds[51]= CRGB::Purple;
leds[52]= CRGB::Purple;
leds[53]= CRGB::Purple;
leds[54]= CRGB::Purple;
leds[55]= CRGB::Purple;
leds[56]= CRGB::Purple;
leds[57]= CRGB::Purple;
leds[58]= CRGB::Purple;
leds[59]= CRGB::Purple;
leds[60]= CRGB::Purple;
leds[61]= CRGB::Purple;
leds[62]= CRGB::Purple;
leds[63]= CRGB::Purple;
leds[64]= CRGB::Purple;
leds[65]= CRGB::Purple;
leds[66]= CRGB::Purple;
leds[67]= CRGB::Purple;
leds[68]= CRGB::Purple;
leds[69]= CRGB::Purple;
leds[70]= CRGB::Purple;
leds[71]= CRGB::Purple;
leds[72]= CRGB::Purple;
leds[73]= CRGB::Purple;
leds[74]= CRGB::Purple;
leds[75]= CRGB::Purple;
leds[76]= CRGB::Purple;
FastLED.show();
}
void Star_Tree_Display () {
leds[77]= CRGB::Green;
leds[78]= CRGB::Green;
leds[79]= CRGB::Green;
leds[80]= CRGB::Green;
leds[81]= CRGB::Green;
leds[82]= CRGB::Green;
leds[83]= CRGB::Green;
leds[84]= CRGB::Green;
leds[85]= CRGB::Yellow;
leds[86]= CRGB::Yellow;
leds[87]= CRGB::Yellow;
leds[88]= CRGB::Yellow;
leds[89]= CRGB::Yellow;
leds[90]= CRGB::Yellow;
leds[91]= CRGB::Yellow;
leds[92]= CRGB::Yellow;
leds[93]= CRGB::Yellow;
leds[94]= CRGB::Yellow;
leds[95]= CRGB::Yellow;
leds[96]= CRGB::Yellow;
leds[97]= CRGB::Yellow;
leds[98]= CRGB::Yellow;
leds[99]= CRGB::Yellow;
leds[100]= CRGB::Yellow;
leds[101]= CRGB::Yellow;
leds[102]= CRGB::Yellow;
leds[103]= CRGB::Yellow;
leds[104]= CRGB::Yellow;
leds[105]= CRGB::Red;
leds[106]= CRGB::Red;
leds[107]= CRGB::Red;
leds[108]= CRGB::Red;
FastLED.show();
}