FastLed vs Neopixel vs Audio library - CPU overload?

Status
Not open for further replies.
Hello there,
I have a similar problem and I think all the posts above should give me the answer, but I can't seem to find it.
I want to build a light saber for a school project, but haven't really worked with microcontrollers in the past.
When I 'power up' the lightsaber, the LEDs work, but the sound stops playing very shortly after and tries to start again multiple times a second. I tried implementing the things posted above and switched from FastLED to Paul's WS2812Serial library, but I must still do something wrong. The basic test example, included in the library, worked just fine.
I use a Teensy 3.2 with a prop shield (no LC).
I am german, so I hope you understand me. Thank you very much!
Paul
Code:
#include <WS2812Serial.h> //LED
#include <Audio.h> //Audio
#include <NXPMotionSense.h> //Motion
#include <Wire.h> //Audio, Motion
#include <EEPROM.h> //Motion
#include <SPI.h> //Audio
#include <SD.h> //Audio
#include <SerialFlash.h> //Audio

//LED strip
const int numled = 144;
const int pin = 1;
byte drawingMemory[numled*3];         //  3 bytes per LED
DMAMEM byte displayMemory[numled*12]; // 12 bytes per LED
WS2812Serial leds(numled, displayMemory, drawingMemory, pin, WS2812_GRB);

#define RED    0xFF0000
#define GREEN  0x00FF00
#define BLUE   0x0000FF
#define LBLUE  0x00FFFF
#define ORANGE 0xFF8000
#define BLACK  0x000000


// Taster, DG
#define POWER_PIN 15
#define COLOR_PIN 17

//Audio
#define SDCARD_CS_PIN    4
#define SDCARD_MOSI_PIN  11
#define SDCARD_SCK_PIN   13


// Variable for changing colors
int d = 0;
int LAST_POWER_STATUS=LOW;

// lightsaber status
bool RUNNING = false;


NXPMotionSense imu; 
NXPSensorFusion filter; 

//Audio
AudioPlaySdWav           playSdWav1;
AudioOutputAnalog        dac1; 
AudioConnection          patchCord1(playSdWav1, 0, dac1, 0);
AudioConnection          patchCord2(playSdWav1, 1, dac1, 1);


//Motion
int a; 
int acc_rms;


//function power up lightsaber
void einschalten(int color, int wait){ 
   playSdWav1.play("TeensySF/out01.wav");
   delay(10); // wait for library to parse WAV info
   for (int i=0; i < leds.numPixels(); i++) {
    leds.setPixel(i, color);
    leds.show();
    delayMicroseconds(wait);
  }
  
 for (int i=0; i < leds.numPixels(); i++) {
    leds.setPixel(i, RED);
  }
  leds.show();

  RUNNING = true;
}

//function power off lightsaber
void ausschalten(int color, int wait){ 
  playSdWav1.play("TeensySF/in01.wav");
  delay(10); // wait for library to parse WAV info
   for (int i=144; i >= 0; i--) {
    leds.setPixel(i, color);
    leds.show();
    delayMicroseconds(wait);
  }

  RUNNING = false;
  int d=0;
}



  
void setup() {
  Serial.begin(9600); 
  imu.begin(); 
  filter.begin(100); 
  delay(1000); 
  
 
 
  pinMode(POWER_PIN, INPUT);
  pinMode(COLOR_PIN, INPUT);
  pinMode(pin, OUTPUT);
 
  leds.begin();
  leds.show();

  
  //Audio
  AudioMemory(8); 
  dac1.analogReference(EXTERNAL); // much louder!
  delay(50);             // time for DAC voltage stable
  pinMode(5, OUTPUT);
  digitalWrite(5, HIGH); // turn on the amplifier
  delay(10);             // allow time to wake up
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }
   delay(1000);
}  //Audio ende
  


 
 

void loop() { 
  
    int POWER_PIN_STATUS=digitalRead(POWER_PIN); // LOW when pressed / HIGH not
    int COLOR_PIN_STATUS=digitalRead(COLOR_PIN);
    Serial.println(POWER_PIN_STATUS);
    
    int microsec = 1500 / leds.numPixels();
     //Hum
    

  float ax, ay, az; 

  float gx, gy, gz; 

  float mx, my, mz; 

  float roll, pitch, heading; 

  if (imu.available()) { 

    // Read the motion sensors 

    imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz); 

   

    // Update the SensorFusion filter 

    filter.update(gx, gy, gz, ax, ay, az, mx, my, mz); 

   

    // print the heading, pitch and roll 
    roll = filter.getRoll(); 
    pitch = filter.getPitch(); 
    heading = filter.getYaw(); 
    Serial.print("Orientation: "); 
    Serial.print(heading); 
    Serial.print(" ");
    Serial.print(pitch);
    Serial.print(" "); 
    Serial.println(roll); 
    a=abs(roll/3); 
    Serial.print(" "); 
    acc_rms=sqrt(ax*ax+ay*ay+az*az)/3; 

    Serial.println(acc_rms); 
    
    //condition clash activation
    if(acc_rms==1 && RUNNING) 
    { 
       for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, RED);
      }
      leds.show();
      Serial.println("ShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShake");
    } 

      // power on and off button
    if(POWER_PIN_STATUS != LAST_POWER_STATUS && POWER_PIN_STATUS == LOW){
      if(RUNNING){
        ausschalten(BLACK, microsec);
      }else {
        einschalten(RED, microsec);
      }
    }
    
    LAST_POWER_STATUS = POWER_PIN_STATUS;
    
    
    
    // different running colors
    if(RUNNING && d==0) {
      for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, RED);
      }
      leds.show();
      Serial.println("Just runnin red");
    }
    if(RUNNING && d==1) {
      for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, GREEN);
      }
      leds.show();
      Serial.println("Just runnin green");
    }
     if(RUNNING && d==2) {
      for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, LBLUE);
      }
      leds.show();
      Serial.println("Just runnin light blue");
    }
     if(RUNNING && d==3) {
      for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, BLUE);
      }
      leds.show();
      Serial.println("Just runnin blue");
    }
    if(RUNNING && d==4) {
      for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, ORANGE);
      }
      leds.show();
      Serial.println("Just runnin orange");
    }

   if (  RUNNING) { //
    Serial.println("Start playing");
    playSdWav1.play("SmthJedi/hum01.wav");
    delay(10); // wait for library to parse WAV info}
    }
    
 

    if(COLOR_PIN_STATUS==LOW && RUNNING)
      {d++;
      delay(200);}
      Serial.println(d);

    if (RUNNING == false) d=0;
     
    if (d == 5) d = 0;
   
    }}
 
I implemented Bounce 2 and now the sound does not stop after a short time. Next I want to get rid of alle the unnecessary delays and replace them with millis and I have to get rid of the gap between the start up sound and the humming.
Another problem that occured now is, that by pressing my color switch button once, it is registered as two pushes.
But I am happy that things are getting better. It seems like the sheer thought of you helping me out already helps me :D
Code:
#include <Bounce2.h>

#include <WS2812Serial.h> //LED
#include <Audio.h> //Audio
#include <NXPMotionSense.h> //Motion
#include <Wire.h> //Audio, Motion
#include <EEPROM.h> //Motion
#include <SPI.h> //Audio
#include <SD.h> //Audio
#include <SerialFlash.h> //Audio


//LED strip
const int numled = 144;
const int pin = 1;
byte drawingMemory[numled*3];         //  3 bytes per LED
DMAMEM byte displayMemory[numled*12]; // 12 bytes per LED
WS2812Serial leds(numled, displayMemory, drawingMemory, pin, WS2812_GRB);

#define RED    0xFF0000
#define GREEN  0x00FF00
#define BLUE   0x0000FF
#define LBLUE  0x00FFFF
#define ORANGE 0xFF8000
#define BLACK  0x000000


// Taster, DG
#define POWER_PIN 15
#define COLOR_PIN 17

// Instantiate two Bounce objects
Bounce debouncer1 = Bounce(); //Power Pin

Bounce debouncer2 = Bounce(); //Color Pin

//Audio
#define SDCARD_CS_PIN    4
#define SDCARD_MOSI_PIN  11
#define SDCARD_SCK_PIN   13


// Variable for changing colors
int d = 0;
int LAST_POWER_STATUS=LOW;

// lightsaber status
bool RUNNING = false;


NXPMotionSense imu; 
NXPSensorFusion filter; 

//Audio
AudioPlaySdWav           playSdWav1;
AudioOutputAnalog        dac1; 
AudioConnection          patchCord1(playSdWav1, 0, dac1, 0);
AudioConnection          patchCord2(playSdWav1, 1, dac1, 1);


//Motion
int a; 
int acc_rms;


//function power up lightsaber
void einschalten(int color, int wait){ 
   playSdWav1.play("TeensySF/out01.wav");
   delay(10); // wait for library to parse WAV info
   for (int i=0; i < leds.numPixels(); i++) {
    leds.setPixel(i, color);
    leds.show();
    delayMicroseconds(wait);
  }
  
 for (int i=0; i < leds.numPixels(); i++) {
    leds.setPixel(i, RED);
  }
  leds.show();

  RUNNING = true;
}

//function power off lightsaber
void ausschalten(int color, int wait){ 
  playSdWav1.play("TeensySF/in01.wav");
  delay(10); // wait for library to parse WAV info
   for (int i=144; i >= 0; i--) {
    leds.setPixel(i, color);
    leds.show();
    delayMicroseconds(wait);
  }

  RUNNING = false;
  int d=0;
}



  
void setup() {
  Serial.begin(9600); 
  imu.begin(); 
  filter.begin(100); 
  delay(1000); 
  
 
 
  pinMode(POWER_PIN, INPUT_PULLUP);
  debouncer1.attach(POWER_PIN); //POWER_PIN is assigned to debouncer1
  debouncer1.interval(10); //interval
  
  pinMode(COLOR_PIN, INPUT_PULLUP);
  debouncer2.attach(COLOR_PIN); //COLOR_PIN is assigned to debouncer2
  debouncer2.interval(10);
  
  pinMode(pin, OUTPUT);
 
  leds.begin();
  leds.show();

  
  //Audio
  AudioMemory(8); 
  dac1.analogReference(EXTERNAL); // much louder!
  delay(50);             // time for DAC voltage stable
  pinMode(5, OUTPUT);
  digitalWrite(5, HIGH); // turn on the amplifier
  delay(10);             // allow time to wake up
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }
   delay(1000);
}  //Audio ende
  


 
 

void loop() { 
  
   // update Bounce instances  
  debouncer1.update();
  debouncer2.update();
 
    int POWER_PIN_STATUS=debouncer1.read(); // LOW when pressed / HIGH not
    int COLOR_PIN_STATUS=debouncer2.read();
    Serial.println(POWER_PIN_STATUS);
    
    int microsec = 1500 / leds.numPixels();
     //Hum

  float ax, ay, az; 

  float gx, gy, gz; 

  float mx, my, mz; 

  float roll, pitch, heading; 

  if (imu.available()) { 

    // Read the motion sensors 

    imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz); 

   

    // Update the SensorFusion filter 

    filter.update(gx, gy, gz, ax, ay, az, mx, my, mz); 

   

    // print the heading, pitch and roll 
    roll = filter.getRoll(); 
    pitch = filter.getPitch(); 
    heading = filter.getYaw(); 
    Serial.print("Orientation: "); 
    Serial.print(heading); 
    Serial.print(" ");
    Serial.print(pitch);
    Serial.print(" "); 
    Serial.println(roll); 
    a=abs(roll/3); 
    Serial.print(" "); 
    acc_rms=sqrt(ax*ax+ay*ay+az*az)/3; 

    Serial.println(acc_rms); 
    
    //condition clash activation
    if(acc_rms==1 && RUNNING) 
    { 
       for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, RED);
      }
      leds.show();
      Serial.println("ShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShakeShake");
    } 

      // power on and off button
    if(POWER_PIN_STATUS != LAST_POWER_STATUS && POWER_PIN_STATUS == LOW){
      if(RUNNING){
        ausschalten(BLACK, microsec);
      }else {
        einschalten(RED, microsec);
      }
    }
    
    LAST_POWER_STATUS = POWER_PIN_STATUS;
    
    
    
    // different running colors
    if(RUNNING && d==0) {
      for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, RED);
      }
      leds.show();
      Serial.println("Just runnin red");
    }
    if(RUNNING && d==1) {
      for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, GREEN);
      }
      leds.show();
      Serial.println("Just runnin green");
    }
     if(RUNNING && d==2) {
      for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, LBLUE);
      }
      leds.show();
      Serial.println("Just runnin light blue");
    }
     if(RUNNING && d==3) {
      for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, BLUE);
      }
      leds.show();
      Serial.println("Just runnin blue");
    }
    if(RUNNING && d==4) {
      for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, ORANGE);
      }
      leds.show();
      Serial.println("Just runnin orange");
    }

   if (playSdWav1.isPlaying() == false  &&  RUNNING) { //
    Serial.println("Start playing");
    playSdWav1.play("SmthJedi/hum01.wav");
    delay(10); // wait for library to parse WAV info}
    }
    
 

    if(COLOR_PIN_STATUS==LOW && RUNNING)
      {d++;
      delay(200);}
      Serial.println(d);

    if (RUNNING == false) d=0;
     
    if (d == 5) d = 0;
   
    }}
 
Last edited:
You might want to use the Bounce2 function fell that returns true when the pin returns LOW for the first time after debouncing. Similarly, rose returns true when the pin transitions from LOW to HIGH.
 
Thank you for the tip, I've looked through many threads and it's amazing how fast you are with replying to problems.
I'll try fell() and rose() out later. For now I kind of cheated, by changing the code so that the colors changes when the counter goes up by two.
 
Unfortunately there is another problem occuring, after a while, but almost always after shaking the teensy to trigger the clash-action, it crashes. I thought the motion sensor might be the problem's cause, but commenting these parts out didn't make a difference.
Does anyone have any advice for me or is able to find the root of the problem?
Thank you very much!

Code:
#include <Bounce2.h> //reading button status won't interfere with sound
#include <millisDelay.h> // used to avoid delays
#include <WS2812Serial.h> //LED
#include <Audio.h> //Audio
#include <NXPMotionSense.h> //Motion
#include <Wire.h> //Audio, Motion
#include <EEPROM.h> //Motion, access the calibrated motion sensor data stored in eeprom
#include <SPI.h> //Audio
#include <SD.h> //Audio
#include <SerialFlash.h> //Audio

//LED strip
const int numled = 144;
const int pin = 1;
byte drawingMemory[numled*3];         //  3 bytes per LED
DMAMEM byte displayMemory[numled*12]; // 12 bytes per LED
WS2812Serial leds(numled, displayMemory, drawingMemory, pin, WS2812_GRB);

#define RED    0xFF0000
#define REDF   0x780707
#define GREEN  0x00FF00
#define GREENF  0x009c00
#define BLUE   0x0000FF
#define BLUEF   0x0505ab
#define LBLUE  0x00FFFF
#define LBLUEF  0x07a3a3
#define BLACK  0x000000

//Flicker
float delayStart = 0; // the time the delay started
bool delayRunning = false; // true if still waiting for delay to finish
bool flicker = false; // keep track of the led state

// Taster & DG
#define POWER_PIN 15
#define COLOR_PIN 17
          
// Instantiate two Bounce objects
Bounce debouncer1 = Bounce(); //Power Pin
Bounce debouncer2 = Bounce(); //Color Pin


//Audio
#define SDCARD_CS_PIN    4
#define SDCARD_MOSI_PIN  11
#define SDCARD_SCK_PIN   13
long randclsh;

// Variable for changing colors
int d = 0;

// lightsaber status
int LAST_POWER_STATUS=LOW;
bool RUNNING = false;

//Audio
AudioPlaySdWav           playSdWav1;     //xy=72,268
AudioPlaySdWav           playSdWav2;     //xy=79,388
AudioEffectFade          fade2;          //xy=215,304
AudioEffectFade          fade1;          //xy=220,229
AudioMixer4              mixer1;         //xy=358,250
AudioOutputAnalog        dac1;           //xy=527,254
AudioConnection          patchCord1(playSdWav1, 0, fade1, 0);
AudioConnection          patchCord2(playSdWav1, 1, fade2, 0);
AudioConnection          patchCord3(playSdWav2, 0, mixer1, 1);
AudioConnection          patchCord4(playSdWav2, 1, mixer1, 3);
AudioConnection          patchCord5(fade2, 0, mixer1, 2);
AudioConnection          patchCord6(fade1, 0, mixer1, 0);
AudioConnection          patchCord7(mixer1, dac1);

//Motion
NXPMotionSense imu; 
NXPSensorFusion filter; 
int a; 
int acc_rms;

//function power up lightsaber
void einschalten(int color, int wait){ 
   playSdWav2.play("SmthJedi/out01.wav");
    fade1.fadeIn(100);
    fade2.fadeIn(100);
   playSdWav1.play("SmthJedi/hum01.wav");
   delay(10); // wait for library to parse WAV info
   for (int i=0; i < leds.numPixels(); i++) {
    leds.setPixel(i, color);
    leds.show();
    delayMicroseconds(wait);
  }
  for (int i=0; i < leds.numPixels(); i++) {
    leds.setPixel(i, RED);
  }
  leds.show();

  RUNNING = true;
  }

//function power off lightsaber
void ausschalten(int color, int wait){ 
  playSdWav2.play("SmthJedi/in01.wav");
  delay(10); // wait for library to parse WAV info
  for (int i=144; i >= 0; i--) {
    leds.setPixel(i, color);
    leds.show();
    delayMicroseconds(wait);
    fade1.fadeOut(1000);
    fade2.fadeOut(1000);
  }
  RUNNING = false;
  int d=0;
}
      
void setup() {
  Serial.begin(9600); 
  imu.begin(); 
  filter.begin(100); 
  delay(1000); 
  
 //Flicker  
    flicker = false;   
    delayStart = millis();
    delayRunning = true;
 
  pinMode(POWER_PIN, INPUT_PULLUP);
  debouncer1.attach(POWER_PIN); //POWER_PIN is assigned to debouncer1
  debouncer1.interval(10); //interval
  
  pinMode(COLOR_PIN, INPUT);
  debouncer2.attach(COLOR_PIN); //COLOR_PIN is assigned to debouncer2
  debouncer2.interval(10);
  
  pinMode(pin, OUTPUT);
 
  leds.begin();
  leds.show();

  //Audio
  AudioMemory(8); 
  dac1.analogReference(EXTERNAL); // much louder!
  delay(50);             // time for DAC voltage stable
  pinMode(5, OUTPUT);
  digitalWrite(5, HIGH); // turn on the amplifier
  delay(10);             // allow time to wake up
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }
   mixer1.gain(0, 0.5);
   mixer1.gain(1, 0.4);
   mixer1.gain(2, 0.5);
   mixer1.gain(3, 0.4);
   delay(1000);
//Audio ende

}  

void loop() { 

//currentMillis = millis();


if ( playSdWav1.isPlaying() == false && RUNNING) { //
    Serial.println("Start playing");
    playSdWav1.play("SmthJedi/hum01.wav");
    delay(10); // wait for library to parse WAV info}
    }
  
   // update Bounce instances  
  debouncer1.update();
  debouncer2.update();
 
    int POWER_PIN_STATUS=debouncer1.read(); // LOW when pressed / HIGH not
    int COLOR_PIN_STATUS=debouncer2.read();
    Serial.println(POWER_PIN_STATUS);
    
    int microsec = 1500 / leds.numPixels();
     
//Motion
  float ax, ay, az; 

  float gx, gy, gz; 

  float mx, my, mz; 

  float roll, pitch, heading; 

   if (imu.available()) { 
    // Read the motion sensors 
    imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz); 
    // Update the SensorFusion filter 
    filter.update(gx, gy, gz, ax, ay, az, mx, my, mz); 
    // print the heading, pitch and roll 
    roll = filter.getRoll(); 
    pitch = filter.getPitch(); 
    heading = filter.getYaw(); 
    Serial.print("Orientation: "); 
    Serial.print(heading); 
    Serial.print(" ");
    Serial.print(pitch);
    Serial.print(" "); 
    Serial.println(roll); 
    a=abs(roll/3); 
    Serial.print(" "); 
    acc_rms=sqrt(ax*ax+ay*ay+az*az)/3; 

    Serial.println(acc_rms); 
    randclsh = random (1,9);
      String cstring1 = "SmthJedi/clsh0";
      String cstring2 = ".wav";
      String clsh = cstring1 + randclsh + cstring2;
   
 //condition clash activation
 if(acc_rms==1 && RUNNING ) 
    { 
      playSdWav2.play(clsh.c_str());
      delay(10);
       for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, GREEN);
      }
      leds.show();
      delay(random(10,80));
      Serial.println("Shake");
    } 
    
      // power on and off button
    if(POWER_PIN_STATUS != LAST_POWER_STATUS && POWER_PIN_STATUS == LOW){
      if(RUNNING){
        ausschalten(BLACK, microsec);
      }else {
        einschalten(RED, microsec);
      }
    }
    
    LAST_POWER_STATUS = POWER_PIN_STATUS;
int DELAY_TIME = random(70,100);
    // different running colors
    if(RUNNING && d==0) {
      if (delayRunning && ((millis() - delayStart) >= DELAY_TIME)) {
    delayStart += DELAY_TIME; // this prevents drift in the delays
    // toggle the led
    flicker = !flicker;
    if (flicker) {
     for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, RED);
      }
      leds.show();
      Serial.println("Just runnin red"); 
    }
    else {
     for (int i=0; i < leds.numPixels(); i=i+2) {
      leds.setPixel(i, REDF);
      }
      leds.show();
      Serial.println("Just runnin dark red");
      }
    }
  }
   
   if(RUNNING && d==2) {if (delayRunning && ((millis() - delayStart) >= DELAY_TIME)) {
    delayStart += DELAY_TIME; // this prevents drift in the delays
    // toggle the led
    flicker = !flicker;
    if (flicker) {
     for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, GREEN);
      }
      leds.show();
      Serial.println("Just runnin green"); 
    }
    else {
     for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, GREENF);
      }
      leds.show();
      Serial.println("Just runnin dark green");
      }
    }
    }
     if(RUNNING && d==4) {
     if (delayRunning && ((millis() - delayStart) >= DELAY_TIME)) {
    delayStart += DELAY_TIME; // this prevents drift in the delays
    // toggle the led
    flicker = !flicker;
    if (flicker) {
     for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, BLUE);
      }
      leds.show();
      Serial.println("Just runnin blue"); 
    }
    else {
     for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, BLUEF);
      }
      leds.show();
      Serial.println("Just runnin dark blue");
      }
    }
    }
     if(RUNNING && d==6) {
     if (delayRunning && ((millis() - delayStart) >= DELAY_TIME)) {
    delayStart += DELAY_TIME; // this prevents drift in the delays
    // toggle the led
    flicker = !flicker;
    if (flicker) {
     for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, LBLUE);
      }
      leds.show();
      Serial.println("Just runnin lblue"); 
    }
    else {
     for (int i=0; i < leds.numPixels(); i++) {
      leds.setPixel(i, LBLUEF);
      }
      leds.show();
      Serial.println("Just runnin dark lblue");
      }
    }
    }
 
  if(COLOR_PIN_STATUS==LOW && RUNNING)
      {d++;
     // delay(200);
      }
    // Serial.println(d);
    if (RUNNING == false) d=0; 
    if (d == 8) d = 0;
   
    }}
 
Status
Not open for further replies.
Back
Top