Problem coding my second strip

Hey there, i’m pretty new to programming LED so im using the Strandtest Code and altering it.

Right now, i got the fading part on PIN 6 working and wanted to add a permanent red color to my second strip on PIN 3.

The problem is, it’s going on full rainbow mode and I dont even know why, cause I lack insight of the code.

My thoughts were, if I use the ColorWipe part for strip2 with a particular color, it should lighten up in that color, but it does not…its on rainbow somehow.

pls don’t be too hard on me and thank you in advance.

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

#define PIN 6
#define PIN2 3

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(60, PIN2, NEO_GRB + NEO_KHZ800);

int brightness = 0;
int fadeAmount = 20;

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


  strip.begin();
  strip.show();
  strip2.begin();
  strip2.show();
}


void loop() {
  colorWipe2(strip2.Color(255, 0, 0), 0);

  strip.setBrightness(brightness);
  colorWipe(strip.Color(255, 25, 0), 0); // Red

  brightness = constrain(brightness + fadeAmount, 0, 255);

  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount;
  }

}

void colorWipe2(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip2.setPixelColor(i, c);
    strip2.show();
    delay(wait);
  }
}


void colorWipe(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

You need to slow down and do things one step at a time. Instead of chasing a quick cut-and-paste solution, learn how to use the software and hardware. There’s nothing wrong with the code you wrote, except it’s obvious you don’t know how it works. Cut your circuit down to one LED strip. Run through all the examples: colorWipe, rainbow, rainbowCycle, theaterChase, theaterChaseRainbow, Wheel, using different values and see how each responds. when you’re comfortable with the workings of the library you can add the second strip.

If you just want someone to post a solution for you so you can get it working, without fully understanding why, this is the wrong forum.

Thanks, but I did try out all examples, played with it, changed numbers and tried to figure out what is interfering with each other.

Is there a basic..coding guide somehow somewhere? Because im feeling like a blind detectiv right now, wandering around cluelessly, trying to stumble upon a solution somehow.

Why exactly is it going rainbow? I guess its in the ColorWipe part somehow, but I cant tell why its red for PIN6 and rainbow für PIN 3

Steamboy:
Is there a basic..coding guide somehow somewhere? Because im feeling like a blind detectiv right now, wandering around cluelessly, trying to stumble upon a solution somehow.

Try the reference area on this site...

Google "Arduino tutorial"

Google "C++ tutorial"

I’ll take a crack at it although I’m way less than a coding God. In the colorwipe2 routine, you have

for (uint16_t i = 0; i < strip.numPixels(); i++)

shouldn’t that be strip2.numPixels() ???

Hope it helps. It helps to have another pair of eyes some times.

DaleScott:
I’ll take a crack at it although I’m way less than a coding God. In the colorwipe2 routine, you have

for (uint16_t i = 0; i < strip.numPixels(); i++)

shouldn’t that be strip2.numPixels() ???

Hope it helps. It helps to have another pair of eyes some times.

Except it looks like they are both == 60

yea… it doesn’t change anything but thanks^^

I’ve read some tutorials and guides trying to decifer the code and tried to set the PixelColor of Strip2 to something else, but its not working.

void colorWipe2(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip2.setPixelColor(i, c);
    strip2.show();
    delay(wait);

If I change the PixelColor in this part, nothing happens.

I’ve read that “uint32_t c” is a 24-bit RGB color value, 0xRRGGBB and I guess that can be changed somehow and may have something to do with my problem

Well… still don’t see why its rainbow mode :frowning:

Can you disconnect the strip attached to pin6 and construct a test only for the strip on pin3. I've had a long look at the library and I have some serious questions as to whether it can handle two strips at once. The timing seems to be a bit touchy.

Well, the strandtest should be able to, cause I've seen a guide/code on someone using ColorWipe for 1 strip and RainbowCycle for the other, thats why I thought it should work for 2 Colorwipes too.

What kind of test should I be running after disconecting? Strandtest and change it to PIN3?

Just do everything you would normally do for one strip except do it only for the strip attached to pin3. Verify that the strip, pin and constructor are working.

Have you tried switching the pin that's not working correctly to another pin? Might be hardware related. Also make sure you have the wire in the right slot. I can't tell you how many times I was just 1 pin off.