Every_N_Millis -Arduino coding issue

Thread Starter

Mark1015

Joined May 15, 2020
20
I have posted some code that uses the every_n_millis from the FASTLED library. I have looked at the documentation and cant find mention of it anywhere. What i would like to do is have the 0-6 pixels run in order and the 13-7 pixels run in reverse order.(two Neopixel jewels daisy chained). I am not against splitting the pair and using separate pins and separate functions. I wish to avoid delay as this will be part of a larger sketch. This appears to be a nice bit of clean code for my needs.

Two jewels:
// EVERY_N_MILLIS used to replace delay by Chemdoc77


#include "FastLED.h"
#define NUM_LEDS 7
#define DATA_PIN 5
#define LED_TYPE NEOPIXEL

int brightness = 30;  // Adjust from 0 to 255 to set brightness.
uint8_t x=0;
CRGB leds[NUM_LEDS];

void setup() {
 delay(2000); // power-up safety delay
 FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, NUM_LEDS);
 FastLED.setBrightness(brightness);
 FastLED.setMaxPowerInVoltsAndMilliamps(5, 1000);
 set_max_power_indicator_LED(13);
 fill_solid(leds, NUM_LEDS, CRGB::Black);
 FastLED.show();
}

void loop() {

   CD77_colorwipe_dot_nodelay (CRGB::Red, 100);
}

//===================================================
void CD77_colorwipe_dot_nodelay(CRGB color, uint32_t wait) {  //without delay               
   EVERY_N_MILLIS(wait){
   x++;
   if (x >=  NUM_LEDS) {x = 0;}
   fill_solid(leds,NUM_LEDS, CRGB::Black);
   leds[x] = color;
   FastLED.show();
  }
} 

void CD77_colorwipe_dot(CRGB color, uint8_t wait) {  // with delay 
for (uint8_t i = 0; i <NUM_LEDS; i++) {
    leds[i] = color;
    FastLED.show();
    delay(wait);
    leds[i] = CRGB::Black;
    FastLED.show();
  }
}
 
Top