Neopixel TheaterChase with 2 strip (one in reverse)

Hi all,

Im a bit stuck with my code. Here's what im trying to do, I would like to simulate blood flow. For this I use two LED strips (one which will be red for oxygenating blood and the other blue for saturating) and I would like to use the TheaterChase effcet to simulate the flow. The problem is that with one function I would like one strip in one direction and the second in the opposite direction.

If you can help me that would be great thanks!

My code at the moment :

void loop() {
  
theaterChaseA(VEINE.Color(255, 0, 0),ARTERE.Color(255, 0, 0), 50);  


}

void theaterChaseA(uint32_t color1, uint32_t color2, int wait) {
  for(int a=0; a<10; a++) {  
    for(int b=0; b<4; b++) {  
      ARTERE.clear();
      VEINE.clear();
    
      for(int c=b; c<VEINE.numPixels(); c += 4) {
        ARTERE.setPixelColor(c - (a+b), color2); // Set pixel 'c' to value 'color'
        VEINE.setPixelColor(c, color1);
      }
      ARTERE.show();
      VEINE.show();// Update strip with new contents
        
      delay(90);
    }
  }


And in case, the project in pic.

That is not a complete sketch. Please post the entire sketch so people can compile it. It will also indentify which LED library you are using.

1 Like

My bad, sorry

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

#define PINA 10
#define PINV 11

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel ARTERE = Adafruit_NeoPixel(25, PINA, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel VEINE = Adafruit_NeoPixel(25, PINV, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  // End of trinket special code

  ARTERE.begin();
  ARTERE.setBrightness(255);
  ARTERE.show(); // Initialize all pixels to 'off'

  VEINE.begin();
  VEINE.setBrightness(255);
  VEINE.show(); // Initialize all pixels to 'off'


}




void loop() {
  // put your main code here, to run repeatedly:
theaterChaseA(VEINE.Color(0, 255, 0),ARTERE.Color(0, 0, 255), 50);  


}

void theaterChaseA(uint32_t color1, uint32_t color2, int wait) {
  for(int a=0; a<10; a++) {  // Repeat 10 times...
    for(int b=0; b<4; b++) { //  'b' counts from 0 to 3... 
      ARTERE.clear();
      VEINE.clear();//   Set all pixels in RAM to 0 (off)
      // 'c' counts up from 'b' to end of strip in steps of 4...
      for(int c=b; c<VEINE.numPixels(); c += 4) {
        ARTERE.setPixelColor(c - (a+b), color2); // Set pixel 'c' to value 'color'
        VEINE.setPixelColor(c, color1);
      }
      ARTERE.show();
      VEINE.show();// Update strip with new contents
        
      delay(90);
    }
  }
}saisissez ou collez du code ici

Doesn't that code already do what you are asking? It appears to go in opposite directions for me

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