Arduino star with rtc and light sensor

I may be missing something here. I have looked at the code logically and it should have worked. When turning on the star, the LEDs lights up and running patterns, disregarding the lights_ON state. That's not what I wanted. See flowchart attached.

Attached are the files
schematics.

Please paste your code in your post. Formatted. No one wants to download files and use the IDE just to view your code.

And your flowchart is not complete. Your first decision checks if hour is 0 or if it is greater than 13. What if it's 7? Your flowchart is incomplete.

Also you check if lights_ON is true. It's always false at that point.

appears to be running ok but at pattern #6, arduino some how "resets" itself. Without the sensors, it was flawless running the patterns.
here's the code:

#include <FastLED.h>
#include <BH1750.h>  // Light sensor
#include <TimeLib.h> 
#include "RTClib.h" // Date and time functions using a DS3231 RTC connected via I2C and Wire lib
#include <Wire.h>

BH1750 lightMeter;
RTC_DS3231 rtc; // real time clock

FASTLED_USING_NAMESPACE
// FastLED "100-lines-of-code" demo reel, showing just a few 
// of the kinds of animation patterns you can quickly and easily 
// compose using FastLED.  
//
// This example also shows one easy way to define multiple 
// animations patterns and have them automatically rotate.
//
// -Mark Kriegsman, December 2014

#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif
#define EXE_INTERVAL_1 1000
#define EXE_INTERVAL_2 3000
#define DATA_PIN    6
//#define CLK_PIN   4
#define LED_TYPE    WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS    160
CRGB leds[NUM_LEDS];

#define BRIGHTNESS          35 // 96
#define FRAMES_PER_SECOND  120
bool lights_ON = true;
bool light_sensor_enable = false;
float lux = 0.00;
short lux_resolution = 10;
unsigned long lastExecutedMillis_1 = 0; // vairable to save the last executed time for code block 1
unsigned long lastExecutedMillis_2 = 0; // vairable to save the last executed time for code block 2

void setup() 
{
  Wire.begin(); // Initialize the I2C bus (BH1750 library doesn't do this automatically)
  Serial.begin(9600);
  delay(5000); // 3 second delay for recovery
  
  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);

  lightMeter.begin();

  // Initialize the rtc object
  rtc.begin();

   // When time needs to be re-set on a previously configured device, the
  // following line sets the RTC to the date & time this sketch was compiled
  //rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  // This line sets the RTC with an explicit date & time, for example to set
  // January 21, 2014 at 3am you would call:
  //rtc.adjust(DateTime(2022, 12, 13, 16, 30, 0)); // 4:30PM
  rtc.adjust(DateTime(2022, 12, 13, 23, 58, 0));   // 11:58PM
  //rtc.adjust(DateTime(2022, 12, 13, 19, 03, 0)); // 6AM
}


// List of patterns to cycle through.  Each is defined as a separate function below.
typedef void (*SimplePatternList[])();


SimplePatternList gPatterns = { rainbow, 
                                  rainbowWithGlitter, 
                                  confetti, 
                                  sinelon, 
                                  juggle, 
                                  bpm, 
                                  rainbowCycle,
                                  TheatreChaseRed,
                                  TheatreChaseWhite,
                                  TheatreChaseBlue,
                                  TheatreChaseGreen,
                                  TheatreChaseRandom,
                                  TheatreChaseRainbow,
                                  ColorWipe,
                                  ColorWipeDiffColorLine,
                                  Sparkle,
                                  RunningLights,
                                  //centerToOutFull_8,  // bug
                                  //centerToOutFull_4,
                                  //centerToOutFwd,     // bug
                                  //centerToOutBwd,     // bug
                                  drawStar,
                                  spinningArrow
                                  };

//SimplePatternList gPatterns = { spinningArrow };

//SimplePatternList gPatterns = { spinningArrow };
// drawStar

uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
  
void loop()
{
  read_sensors();
 
  if (lights_ON)
  {
    // Call the current pattern function once, updating the 'leds' array
    gPatterns[gCurrentPatternNumber]();

    // send the 'leds' array out to the actual LED strip
    FastLED.show();  
    // insert a delay to keep the framerate modest
    FastLED.delay(1000/FRAMES_PER_SECOND); 

    // do some periodic updates
    EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color"   through the rainbow
    EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
  }
  else
  {
    
    setAll(0, 0, 0);
    //showStrip();
    FastLED.show();
  }
}

#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern()
{
  // add one to the current pattern number, and wrap around at the end
  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}

void read_sensors()
{
  DateTime now = rtc.now();
  float lux = lightMeter.readLightLevel();
  short lux_resolution = lux / 10;
  unsigned long currentMillis = millis();

  if (currentMillis - lastExecutedMillis_1 >= EXE_INTERVAL_1) 
  {
    lastExecutedMillis_1 = currentMillis; // save the last executed time
    
    now = rtc.now();
  }

  if (currentMillis - lastExecutedMillis_2 >= EXE_INTERVAL_2)
  {
    lastExecutedMillis_2 = currentMillis; // save the last executed time
  
    lux = lightMeter.readLightLevel();
    lux_resolution = lux / 10;

    if (now.hour() == 00 && lights_ON)
    {
      lights_ON = false;
      light_sensor_enable = false;
    }
    else
    {
      if (lux_resolution > 2 && !light_sensor_enable)
      {
        light_sensor_enable = true;
        lights_ON = false;
      }
    
      if (lux_resolution < 2 && light_sensor_enable)
      {
        //dark_time = now.hour();
        lights_ON = true;
      }
    }
  }
  
  Serial.print(lux_resolution);
  Serial.print("enable on = ");
  Serial.print(light_sensor_enable);
  Serial.print(";  lux_resolution = ");
  Serial.print(lux_resolution);    
  Serial.print(";  pattern = ");
  Serial.print(gCurrentPatternNumber);
  Serial.print(";  lights on = ");
  Serial.println(lights_ON);
}

void rainbow() 
{
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, NUM_LEDS, gHue, 7);
}

void rainbowWithGlitter() 
{
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter) 
{
  if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::White;
  }
}

void confetti() 
{
  // random colored speckles that blink in and fade smoothly
  fadeToBlackBy( leds, NUM_LEDS, 10);
  int pos = random16(NUM_LEDS);
  leds[pos] += CHSV( gHue + random8(64), 200, 255);
}

void sinelon()
{
  // a colored dot sweeping back and forth, with fading trails
  fadeToBlackBy( leds, NUM_LEDS, 20);
  int pos = beatsin16( 13, 0, NUM_LEDS-1 );
  leds[pos] += CHSV( gHue, 255, 192);
}

void spinningArrow()
{
  SpinningArrow(400);
}

void SpinningArrow(int SpeedDelay)
{
    //SpeedDelay = 3000;
    // step 1
    for (int i = 0; i <= 64; i ++)
      setPixel(i, 0xFF, 0xFF, 0xFF);
    
    for (int i = 96; i <= 128; i ++)
      setPixel(i, 0xFF, 0xFF, 0xFF);
    
    showStrip();
    delay(SpeedDelay);
    setAll(0, 0, 0);
    
    // step 2
    for (int i = 32; i <= 96; i ++)
        setPixel(i, 0xFF, 0xFF, 0xFF);
        
    for (int i = 128; i <= 159; i ++)
        setPixel(i, 0xFF, 0xFF, 0xFF);
    
    setPixel(0, 0xFF, 0xFF, 0xFF);        
    
    showStrip();
    delay(SpeedDelay);
    setAll(0, 0, 0);
    
    // step 3
    for (int i = 64; i <= 128; i ++)
        setPixel(i, 0xFF, 0xFF, 0xFF);
    
    for (int i = 0; i <= 32; i ++)
        setPixel(i, 0xFF, 0xFF, 0xFF);
    
    showStrip();
    delay(SpeedDelay);
    setAll(0, 0, 0);
    
    // step 4
    for (int i = 96; i <= 159; i ++)
        setPixel(i, 0xFF, 0xFF, 0xFF);
        
    for (int i = 32; i <= 64; i ++)
        setPixel(i, 0xFF, 0xFF, 0xFF);
    
    setPixel(0, 0xFF, 0xFF, 0xFF);

    showStrip();
    delay(SpeedDelay);
    setAll(0, 0, 0);
   
    // step 5
    for (int i = 128; i <= 159; i ++)
        setPixel(i, 0xFF, 0xFF, 0xFF);
    
    for (int i = 0; i <= 32; i ++)
        setPixel(i, 0xFF, 0xFF, 0xFF);

    for (int i = 64; i <= 96; i ++)
        setPixel(i, 0xFF, 0xFF, 0xFF);
    
    showStrip();
    delay(SpeedDelay);
    setAll(0, 0, 0);
}

void drawStar()
{
  DrawStar(50);
}

void DrawStar(int SpeedDelay)
{
  short i = 0;
  
  for(i = 144; i < 160; i++) 
  {
    setPixel(i, 0xFF, 0xFF, 0xFF);
    showStrip();
    delay(delay);
  }

  setPixel(0, 0xFF, 0xFF, 0xFF);
  showStrip();
  delay(delay);
  
  for(i = 32; i <= 64; i++) 
  {
    setPixel(i, 0xFF, 0xFF, 0xFF);
    showStrip();
    delay(delay);
  }

  for(i = 96; i <= 128; i++) 
  {
    setPixel(i, 0xFF, 0xFF, 0xFF);
    showStrip();
    delay(delay);
  }
  

  for(i = 0; i <= 32; i++) 
  {
    setPixel(i, 0xFF, 0xFF, 0xFF);
    showStrip();
    delay(delay);
  }

  for(i = 64; i <= 96; i++) 
  {
    setPixel(i, 0xFF, 0xFF, 0xFF);
    showStrip();
    delay(delay);
  }

  for(i = 128; i <= 144; i++) 
  {
    setPixel(i, 0xFF, 0xFF, 0xFF);
    showStrip();
    delay(delay);
  }

  for(short repeat = 0; repeat < 30; repeat++)
  {
    setAll(random(255), random(255), random(255));
    delay(200);
  }

  setAll(0, 0, 0);
}



void bpm()
{
  // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  uint8_t BeatsPerMinute = 62;
  CRGBPalette16 palette = PartyColors_p;
  uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
  for( int i = 0; i < NUM_LEDS; i++) { //9948
    leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
  }
}

void juggle() 
{
  // eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy( leds, NUM_LEDS, 20);
  byte dothue = 0;
  for( int i = 0; i < 8; i++) {
    leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
    dothue += 32;
  }
}

void rainbowCycle()
{
  rainbowCycle(20);
}

void rainbowCycle(int SpeedDelay) 
{
  byte *c;
  uint16_t i, j;

  for(j=0; j<256*5; j++)  // 5 cycles of all colors on wheel
  {
    for(i=0; i< NUM_LEDS; i++) 
    {
      c=Wheel(((i * 256 / NUM_LEDS) + j) & 255);
      setPixel(i, *c, *(c+1), *(c+2));
    }
      
    showStrip();
    delay(SpeedDelay);
  }
}

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;
}

void FadeInOut()
{
  FadeInOut(0xff, 0x77, 0x00);
}

void FadeInOut(byte red, byte green, byte blue)
{
  float r, g, b;
      
  for(int k = 0; k < 256; k=k+1) 
  { 
    r = (k/256.0)*red;
    g = (k/256.0)*green;
    b = (k/256.0)*blue;
    setAll(r,g,b);
    showStrip();
  }
     
  for(int k = 255; k >= 0; k=k-2) 
  {
    r = (k/256.0)*red;
    g = (k/256.0)*green;
    b = (k/256.0)*blue;
    setAll(r,g,b);
    showStrip();
  }
}

void ColorWipe()
{
  //colorWipe(0x00,0xff,0x00, 50);
  colorWipe(random(255), random(255), random(255), 50);
  colorWipe(0x00,0x00,0x00, 50);
}

void ColorWipeDiffColorLine()
{
  colorWipeDiffColorLine(50);
}

void colorWipeDiffColorLine(int SpeedDelay) 
{
  short cRed = 0xFF;
  short cGreen = 0xFF;
  short cBlue = 0xFF;
      
  for(uint16_t i=0; i<NUM_LEDS; i++) 
  {
    if ((i % 16) == 0)
    {
      cRed = random(255);
      cGreen = random(255);;
      cBlue = random(255);;
    }
    
    setPixel(i, cRed, cGreen, cBlue);
    showStrip();
    delay(SpeedDelay);
  }
}

void colorWipe(byte red, byte green, byte blue, int SpeedDelay) 
{
  for(uint16_t i=0; i<NUM_LEDS; i++) 
  {
    setPixel(i, red, green, blue);
    showStrip();
    delay(SpeedDelay);
  }
}

void Twinkle()
{
  Twinkle(0xff, 0, 0, 10, 100, false);
}

void Twinkle(byte red, byte green, byte blue, int Count, int SpeedDelay, boolean OnlyOne) 
{
  setAll(0,0,0);
  
  for (int i=0; i<Count; i++) 
  {
     setPixel(random(NUM_LEDS),red,green,blue);
     showStrip();
     delay(SpeedDelay);
  
     if(OnlyOne) 
     { 
       setAll(0,0,0); 
     }
   }
  
  delay(SpeedDelay);
}


void TheatreChaseRandom()
{
  short cRed = 0xFF;
  short cGreen = 0xFF;
  short cBlue = 0xFF;

  EVERY_N_SECONDS( 1.5 ) 
  { 
     cRed = random(255);
     cGreen = random(255);
     cBlue = random(255);
  }
  
  theaterChase(cRed, cGreen, cBlue, 50);
}

void TheatreChaseRed()
{
  theaterChase(0xff,0,0,50);
}

void TheatreChaseGreen()
{
  theaterChase(0x00, 0xFF, 0x00,50);
}

void TheatreChaseWhite()
{
  theaterChase(0xFF,0xFF,0xFF,50);
}

void TheatreChaseBlue()
{
  theaterChase(0,0,0xFF,50);
}

void theaterChase(byte red, byte green, byte blue, int SpeedDelay) 
{
  for (int j=0; j<10; j++)   //do 10 cycles of chasing
  {
    for (int q=0; q < 3; q++) 
    {
      for (int i=0; i < NUM_LEDS; i=i+3)
      {
        setPixel(i+q, red, green, blue);    //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
      }
    }
  }
}

void TheatreChaseRainbow()
{
  theaterChaseRainbow(50);
}

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
       }
    }
  }
}

/*
void centerToOutFwd()
{
  CenterToOutFwd(50);
}

void centerToOutBwd()
{
  CenterToOutBwd(50);
}

void centerToOutFull_8()
{
  CenterToOutFull_8(50);
}

void CenterToOutBwd(int WaveDelay)
{
  short cRed = 0xFF;
  short cGreen = 0xFF;
  short cBlue = 0xFF;
  short on_location = 0;
  short on_location_back = 159;
  short off_location = 8;
  short off_location_back = 153;

  
  for(int s = 0; s < 17; s++) 
    {
        for (int k = 0; k < 8; k++)
        {
          if ((s + k) > 16)
            on_location = s + k - 17;
          else
            on_location = s + k;
            
          if (on_location != 0)
            setPixel(160 - on_location, cRed, cGreen, cBlue);

          //setPixel(on_location, cRed, cGreen, cBlue);
          setPixel(32 - on_location, cRed, cGreen, cBlue);
          setPixel(64 - on_location, cRed, cGreen, cBlue);
          setPixel(96 - on_location, cRed, cGreen, cBlue);
          setPixel(128 - on_location, cRed, cGreen, cBlue);
          
          showStrip();

          if ((s + k + 8) > 16)
            off_location = s + k - 9;
          else
            off_location = s + k + 8;

          if (on_location != 0)
            setPixel(160 - off_location, 0, 0 , 0);
            
          setPixel(off_location, 0, 0, 0);
          setPixel(32 - off_location, 0, 0, 0);
          setPixel(64 - off_location, 0, 0, 0);
          setPixel(96 - off_location, 0, 0, 0);
          setPixel(128 - off_location, 0, 0, 0);
        }
        delay(100);
    }
}

void CenterToOutFwd(int WaveDelay)
{
  //short cRed = 0xFF;
  //short cGreen = 0xFF;
  //short cBlue = 0xFF;
  int cRed = random(255);
  int cGreen = random(255);
  int cBlue = random(255);
  short on_location = 0;
  short on_location_back = 159;
  short off_location = 8;
  short off_location_back = 153;

  for(int s = 0; s < 17; s++) 
    {
        for (int k = 0; k < 8; k++)
        {
          if ((s + k) > 16)
            on_location = s + k - 17;
          else
            on_location = s + k;
            
          setPixel(on_location, cRed, cGreen, cBlue);
          setPixel(on_location + 32, cRed, cGreen, cBlue);
          setPixel(on_location + 64, cRed, cGreen, cBlue);
          setPixel(on_location + 96, cRed, cGreen, cBlue);
          setPixel(on_location + 128, cRed, cGreen, cBlue);

          showStrip();

          if ((s + k + 8) > 16)
            off_location = s + k - 9;
          else
            off_location = s + k + 8;

          setPixel(off_location, 0, 0, 0);
          setPixel(off_location+32, 0, 0, 0);
          setPixel(off_location+64, 0, 0, 0);
          setPixel(off_location+96, 0, 0, 0);
          setPixel(off_location+128, 0, 0, 0);
        }
        delay(100);
    }
}

void centerToOutFull_4()
{
  CenterToOutFull_4(50);
}

void centerToOutFull_4()
{
  CenterToOutFull_4(50);
}

void CenterToOutFull_1(int WaveDelay)
{
  short cRed = random(255);
  short cGreen = random(255);
  short cBlue = random(255);
  
  for (i = 0; i <= 16; i+= 4)
      
  
  
  short on_location = 0;
  short on_location_back = 160;
  short off_location = 4;
  short off_location_back = 157;

  for(int s = 0; s < 17; s++) 
  {
      setPixel(on_location, cRed, cGreen, cBlue);
      
      
        for (int k = 0; k < 4; k++)
        {
          if ((s + k) > 16)
            on_location = s + k - 17;
          else
            on_location = s + k;
            
          setPixel(on_location, cRed, cGreen, cBlue);
          setPixel(on_location + 32, cRed, cGreen, cBlue);
          setPixel(on_location + 64, cRed, cGreen, cBlue);
          setPixel(on_location + 96, cRed, cGreen, cBlue);
          setPixel(on_location + 128, cRed, cGreen, cBlue);

          if (on_location != 0)
            setPixel(160 - on_location, cRed, cGreen, cBlue);
            
          setPixel(32 - on_location, cRed, cGreen, cBlue);
          setPixel(64 - on_location, cRed, cGreen, cBlue);
          setPixel(96 - on_location, cRed, cGreen, cBlue);
          setPixel(128 - on_location, cRed, cGreen, cBlue);

          showStrip();

          if ((s + k + 8) > 16)
            off_location = s + k - 9;
          else
            off_location = s + k + 8;

          if (on_location != 0)
            setPixel(160 - off_location, 0, 0 , 0);
            
          setPixel(off_location, 0, 0, 0);
          setPixel(off_location+32, 0, 0, 0);
          setPixel(off_location+64, 0, 0, 0);
          setPixel(off_location+96, 0, 0, 0);
          setPixel(off_location+128, 0, 0, 0);

          setPixel(off_location, 0, 0, 0);
          setPixel(32 - off_location, 0, 0, 0);
          setPixel(64 - off_location, 0, 0, 0);
          setPixel(96 - off_location, 0, 0, 0);
          setPixel(128 - off_location, 0, 0, 0);
        }
        delay(100);
    }
}

void CenterToOutFull_4(int WaveDelay)
{
  short cRed = random(255);
  short cGreen = random(255);
  short cBlue = random(255);
  //short cRed = 0xFF;
  //short cGreen = 0xFF;
  //short cBlue = 0xFF;
  short on_location = 0;
  short on_location_back = 160;
  short off_location = 4;
  short off_location_back = 157;

  for(int s = 0; s < 17; s++) 
    {
        for (int k = 0; k < 4; k++)
        {
          if ((s + k) > 16)
            on_location = s + k - 17;
          else
            on_location = s + k;
            
          setPixel(on_location, cRed, cGreen, cBlue);
          setPixel(on_location + 32, cRed, cGreen, cBlue);
          setPixel(on_location + 64, cRed, cGreen, cBlue);
          setPixel(on_location + 96, cRed, cGreen, cBlue);
          setPixel(on_location + 128, cRed, cGreen, cBlue);

          if (on_location != 0)
            setPixel(160 - on_location, cRed, cGreen, cBlue);
            
          setPixel(32 - on_location, cRed, cGreen, cBlue);
          setPixel(64 - on_location, cRed, cGreen, cBlue);
          setPixel(96 - on_location, cRed, cGreen, cBlue);
          setPixel(128 - on_location, cRed, cGreen, cBlue);

          showStrip();

          if ((s + k + 8) > 16)
            off_location = s + k - 9;
          else
            off_location = s + k + 8;

          if (on_location != 0)
            setPixel(160 - off_location, 0, 0 , 0);
            
          setPixel(off_location, 0, 0, 0);
          setPixel(off_location+32, 0, 0, 0);
          setPixel(off_location+64, 0, 0, 0);
          setPixel(off_location+96, 0, 0, 0);
          setPixel(off_location+128, 0, 0, 0);

          setPixel(off_location, 0, 0, 0);
          setPixel(32 - off_location, 0, 0, 0);
          setPixel(64 - off_location, 0, 0, 0);
          setPixel(96 - off_location, 0, 0, 0);
          setPixel(128 - off_location, 0, 0, 0);
        }
        delay(100);
    }
}

void CenterToOutFull_8(int WaveDelay)
{
  short cRed = random(255);
  short cGreen = random(255);
  short cBlue = random(255);
  //short cRed = 0xFF;
  //short cGreen = 0xFF;
  //short cBlue = 0xFF;
  short on_location = 0;
  short on_location_back = 160;
  short off_location = 8;
  short off_location_back = 153;

  for(int s = 0; s < 17; s++) 
    {
        for (int k = 0; k < 8; k++)
        {
          if ((s + k) <= 16)
            on_location = s + k - 17;
          else
            on_location = s + k;
            
          setPixel(on_location, cRed, cGreen, cBlue);
          setPixel(on_location + 32, cRed, cGreen, cBlue);
          setPixel(on_location + 64, cRed, cGreen, cBlue);
          setPixel(on_location + 96, cRed, cGreen, cBlue);
          setPixel(on_location + 128, cRed, cGreen, cBlue);

          if (on_location != 0)
            setPixel(160 - on_location, cRed, cGreen, cBlue);
            
          setPixel(32 - on_location, cRed, cGreen, cBlue);
          setPixel(64 - on_location, cRed, cGreen, cBlue);
          setPixel(96 - on_location, cRed, cGreen, cBlue);
          setPixel(128 - on_location, cRed, cGreen, cBlue);

          showStrip();

          if ((s + k + 8) > 16)
            off_location = s + k - 9;
          else
            off_location = s + k + 8;

          if (on_location != 0)
            setPixel(160 - off_location, 0, 0 , 0);
            
          setPixel(off_location, 0, 0, 0);
          setPixel(off_location+32, 0, 0, 0);
          setPixel(off_location+64, 0, 0, 0);
          setPixel(off_location+96, 0, 0, 0);
          setPixel(off_location+128, 0, 0, 0);

          setPixel(off_location, 0, 0, 0);
          setPixel(32 - off_location, 0, 0, 0);
          setPixel(64 - off_location, 0, 0, 0);
          setPixel(96 - off_location, 0, 0, 0);
          setPixel(128 - off_location, 0, 0, 0);
        }
        delay(100);
    }
}

//void CenterToOutFull_8(int WaveDelay)
//{
//  short cRed = random(255);
//  short cGreen = random(255);
//  short cBlue = random(255);
//  //short cRed = 0xFF;
//  //short cGreen = 0xFF;
//  //short cBlue = 0xFF;
//  short on_location = 0;
//  short on_location_back = 160;
//  short off_location = 8;
//  short off_location_back = 153;
//
//  for(int s = 0; s < 17; s++) 
//    {
//        for (int k = 0; k < 8; k++)
//        {
//          if ((s + k) > 16)
//            on_location = s + k - 17;
//          else
//            on_location = s + k;
//            
//          setPixel(on_location, cRed, cGreen, cBlue);
//          setPixel(on_location + 32, cRed, cGreen, cBlue);
//          setPixel(on_location + 64, cRed, cGreen, cBlue);
//          setPixel(on_location + 96, cRed, cGreen, cBlue);
//          setPixel(on_location + 128, cRed, cGreen, cBlue);
//
//          if (on_location != 0)
//            setPixel(160 - on_location, cRed, cGreen, cBlue);
//            
//          setPixel(32 - on_location, cRed, cGreen, cBlue);
//          setPixel(64 - on_location, cRed, cGreen, cBlue);
//          setPixel(96 - on_location, cRed, cGreen, cBlue);
//          setPixel(128 - on_location, cRed, cGreen, cBlue);
//
//          showStrip();
//
//          if ((s + k + 8) > 16)
//            off_location = s + k - 9;
//          else
//            off_location = s + k + 8;
//
//          if (on_location != 0)
//            setPixel(160 - off_location, 0, 0 , 0);
//            
//          setPixel(off_location, 0, 0, 0);
//          setPixel(off_location+32, 0, 0, 0);
//          setPixel(off_location+64, 0, 0, 0);
//          setPixel(off_location+96, 0, 0, 0);
//          setPixel(off_location+128, 0, 0, 0);
//
//          setPixel(off_location, 0, 0, 0);
//          setPixel(32 - off_location, 0, 0, 0);
//          setPixel(64 - off_location, 0, 0, 0);
//          setPixel(96 - off_location, 0, 0, 0);
//          setPixel(128 - off_location, 0, 0, 0);
//        }
//        delay(100);
//    }
//}
*/
void Sparkle()
{
  Sparkle(0xff, 0xff, 0xff, 0);
}

void Sparkle(byte red, byte green, byte blue, int SpeedDelay) 
{
  int Pixel = random(NUM_LEDS);
  setPixel(Pixel,red,green,blue);
  showStrip();
  delay(SpeedDelay);
  setPixel(Pixel,0,0,0);
}

void RunningLights()
{
  //RunningLights(0xff,0xff,0x00, 50);
  RunningLights(random(0xFF), random(0xFF), random(0xFF), 50);
}

void RunningLights(byte red, byte green, byte blue, int WaveDelay) 
{
  int Position=0;
  
  for(int i=0; i<NUM_LEDS*2; i++)
  {
      Position++; // = 0; //Position + Rate;

      for(int i=0; i<NUM_LEDS; i++) 
      {
        // sine wave, 3 offset waves make a rainbow!
        //float level = sin(i+Position) * 127 + 128;
        //setPixel(i,level,0,0);
        //float level = sin(i+Position) * 127 + 128;
        setPixel(i,((sin(i+Position) * 127 + 128)/255)*red,
                   ((sin(i+Position) * 127 + 128)/255)*green,
                   ((sin(i+Position) * 127 + 128)/255)*blue);
      }
      
      showStrip();
      delay(WaveDelay);
  }
}

void RainbowTwinkle()
{
  TwinkleRandom(20, 100, false);
}

void TwinkleRandom(int Count, int SpeedDelay, boolean OnlyOne) 
{
  setAll(0,0,0);
  
  for (int i=0; i<Count; i++) 
  {
     setPixel(random(NUM_LEDS),random(0,255),random(0,255),random(0,255));
     showStrip();
     delay(SpeedDelay);
     
     if(OnlyOne) 
     { 
       setAll(0,0,0); 
     }
   }
  
  delay(SpeedDelay);
}




// edit below:
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();
}

I pointed out flaws in your flowchart. If you are not going to correct them, get rid of the flowchart, it's only confusing everybody.

What sensors?

This might happen if the power is not sufficient. If pattern #6 turns extra many leds on, the voltage might drop at the power source and Arduino resets itself. Well, it kind of crashes or turns off, whatever. That might also turn off the leds, which restores the voltage level and Arduino starts happily all over again. Just guessing here.

Perhaps the sensors you mentioned need their own power, which breaks the camel's back.

Seems to help out that before starting the first pattern, check the sensors. if it's good, then run the whole patterns. it still runs and shuts off at midnight until the next darkness.

I'll see about giving the sensors their own power just in case. thanks!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.