So first off. Thanks for any advise I can get on this. I have some neopixel lights in a gaming console and I am trying to Frankenstein two pieces of code together. There are 2 lights on the chassis. There are also 4 lights in the ports. I want the 2 lights to stay on all the time and the 4 lights to start one by one until finished and then start a breathing effect. My question is, The breathing effect doesn't start after lights are finished with its one by one sequence. How can I write the breathing effect into my code? P.S. The first loop is fine I want to add the void sub_loop1() to the sequence. I really need advise!
#include "FastLED.h"
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, PIN2, NEO_GRB + NEO_KHZ800);
#define PIN 2
#define MAX_FRAMES 6
//
constexpr uint16_t ledPin1 {2};
constexpr uint16_t numLeds1 {4};
//
constexpr uint16_t ledPin2 {3};
constexpr uint16_t numLeds2 {2};
//
CRGB leds_1[numLeds1];
CRGB leds_2[numLeds2];
//
int frameIndex = 1; // skips 0 at start up leds.
int nextFrameIndex() {
if (frameIndex < MAX_FRAMES - 1)
{
return frameIndex + 1; //Each Frame leds turn on 1 by 1.
}
{
}
}
//
void setup(){ //Abilities.
// Addresses LED Boot.
FastLED.addLeds<WS2812B, ledPin1, GRB>(leds_1, numLeds1);
// Addresses Memory Pak LED.
FastLED.addLeds<WS2812B, ledPin2, GRB>(leds_2, numLeds2);
fill_solid(leds_2, numLeds2, CRGB::Purple);
//
strip.begin();
strip.setBrightness(85); // Lower brightness and save eyeballs!
strip.show(); // Initialize all pixels to 'off'
}
//
void loop(){
EVERY_N_MILLISECONDS(790) { // Time in between Port LEDs Turing on.
frameIndex = nextFrameIndex();
setColors(); // Turning this off breaks the Start leds Function.
}
FastLED.show();
{
}
}
//
void setColors(){
switch (frameIndex) {
case 1:
break;
case 2:
leds_1[0].setRGB(192, 4, 205);
break;
case 3:
leds_1[1].setRGB(192, 4, 205);
break;
case 4:
leds_1[2].setRGB(192, 4, 205);
break;
case 5:
leds_1[3].setRGB(192, 4, 205);
break;
}
}
//
void sub_loop1(){
int TOTAL_LEDS = 4;
float MaximumBrightness = 255;
float SpeedFactor = 0.008; // I don't actually know what would look good
float StepDelay = 5; // ms for a step delay on the lights
// Make the lights breathe
for (int i = 0; i < 65535; i++) {
// Intensity will go from 10 - MaximumBrightness in a "breathing" manner
float intensity = MaximumBrightness /2.0 * (1.0 + sin(SpeedFactor * i));
strip.setBrightness(intensity);
// Now set every LED to that color
for (int ledNumber=0; ledNumber<TOTAL_LEDS; ledNumber++) {
strip.setPixelColor(ledNumber, 255, 0, 255);
}
strip.show();
//Wait a bit before continuing to breathe
delay(StepDelay); // - Time in between Port LEDs Turning on.
}
}