How can I Multitask with an Adafruit LED strip?

I have an project for School and I am nearly at the end. We have to light up 2 normal LEDs and one LED should Blink at the same time. At this Point I did not have any Problems until I wanted to combine this with an Adafruit LED strip. Now I have no clue why I cant let them glow at the same Time. Any help or advice?

//START

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__ 
#include <avr/power.h>
#endif

#define LED_PIN(SCL, OUTPUT)

#define LED_COUNT 60

Adafruit_NeoPixel strip(60, SCL,NEO_GRB + NEO_KHZ800);

const int ledPin =  13;      


int ledState = LOW;             
long previousMillis = 0;        


long interval = 475;           

void setup() {
  
  pinMode(ledPin, OUTPUT);   

  #if defined(__AVR_ATtiny85) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif

  strip.begin();
  strip.show();
  strip.setBrightness(50);  

  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
}

void loop()
{
  
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    
    digitalWrite(ledPin, ledState);

  colorWipe(strip.Color(255,   0,   0),50);
  colorWipe(strip.Color(255, 100,   0),50);
  colorWipe(strip.Color(  0, 255,   0),50);
 
  rainbow(40);

  digitalWrite(11, HIGH);
  digitalWrite(12, HIGH);

  }
}

void rainbow(int wait) {
  for(long firstPixelHue =0; firstPixelHue < 5*65536; firstPixelHue += 256) {
    
    strip.rainbow(firstPixelHue);

    strip.show();
  }
}

void colorWipe(uint32_t color, int wait) {
  for(int i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, color);
    strip.show();
  }
}

//ENDE

After strip.show() was a delay(wait)
I'm using a Arduino UNO

What kind of Arduino are you using?

Always show us a good schematic of your proposed circuit. Show us a good image of your ‘actual’ wiring.
Give links to components.

You have to rewrite the Neopexel effects so they are non blocking. That is so the code returns to look at the button every half second or so. This is normally a bit advanced for most users although I have posted examples showing how it is done many times.

Non blocking code

However there is now a simpler way by using a commutable delay you can cancel at the touch of a button.

Commutable Delay

you mixed up your "LED Blinking" and your effect calls on the strip

check the closing } ...of

if(currentMillis - previousMillis > interval)

just handle the blink LED within the {} and let the other code run outside of that if.

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