Trying to trigger second neopixel led strip before second one

Im trying to trigger a second neopixel ledstrip "count up" before the other, but i can't get my code to compile. Im trying to do it with a function that's triggered in the other function.

Here's the code

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

const byte ledPin=D5;
const byte led2Pin=D3;

#define NUMPIXELS      12

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, ledPin, led2Pin, NEO_GRB + NEO_KHZ800);


int delayval = 700; // Vertraging voetstappen
int inPin = D7;   // Input pushbutton
int val = 0;     // variable for reading the pin status
const int GREEN = D1;

void setup() 
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);  // declare LED as output
  pinMode(led2Pin, OUTPUT);  // declare LED 2 as output
  pinMode(inPin, INPUT);    // declare pushbutton as input
  //pinMode(D1, OUTPUT);
}

void loop()
{
 analogWrite(GREEN, 255);
  val = digitalRead(inPin);  // read input value
  if (val == HIGH) 
  {         // check if the input is HIGH (button released)
    Serial.println("HOOOOOG");
    SetPixels();
    
    //digitalWrite(ledPin, LOW);
  } /*else {
    digitalWrite(ledPin, HIGH);
        Serial.println("laag");
  }*/
}

void runfirst() {
  for (int i = 0; i < NUMPIXELS; i++) 
  {

    // pixels.Color takes RGB values, from 255,0,0 up to 0,255,255w
    pixels.setPixelColor(i, pixels.Color(0, 255, 0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).
  }
}



void SetPixels() 
{

  runfirst();

  
  for (int i = 0; i < NUMPIXELS; i++) 
  {

    // pixels.Color takes RGB values, from 255,0,0 up to 0,255,255w
    pixels.setPixelColor(i, pixels.Color(0, 255, 0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).
  }
}

Which board are you using ?
An ESP8266 perhaps as you are using D1, D3, D5 and D7 as pin numbers

Please post the complete text of the error messages that you get

Hey Bob.

Im using the NodeMCU which indeed has d1, d2 and such

Here's the error that i got

Arduino: 1.8.6 (Mac OS X), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

Beyond_S:11:94: error: no matching function for call to 'Adafruit_NeoPixel::Adafruit_NeoPixel(int, const byte&, const byte&, int)'
 Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, ledPin, led2Pin, NEO_GRB + NEO_KHZ800);
                                                                                              ^
/Users/Owner/Documents/Arduino/Beyond_S/Beyond_S.ino:11:94: note: candidates are:
In file included from /Users/Owner/Documents/Arduino/Beyond_S/Beyond_S.ino:1:0:
/Users/Owner/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:122:3: note: Adafruit_NeoPixel::Adafruit_NeoPixel()
   Adafruit_NeoPixel(void);
   ^
/Users/Owner/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:122:3: note:   candidate expects 0 arguments, 4 provided
/Users/Owner/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:121:3: note: Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t, uint8_t, neoPixelType)
   Adafruit_NeoPixel(uint16_t n, uint8_t p=6, neoPixelType t=NEO_GRB + NEO_KHZ800);
   ^
/Users/Owner/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:121:3: note:   candidate expects 3 arguments, 4 provided
/Users/Owner/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:116:7: note: constexpr Adafruit_NeoPixel::Adafruit_NeoPixel(const Adafruit_NeoPixel&)
 class Adafruit_NeoPixel {
       ^
/Users/Owner/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:116:7: note:   candidate expects 1 argument, 4 provided
exit status 1
no matching function for call to 'Adafruit_NeoPixel::Adafruit_NeoPixel(int, const byte&, const byte&, int)'
Board at /dev/cu.SLAB_USBtoUART is not available

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, ledPin, led2Pin, NEO_GRB + NEO_KHZ800);

The error message is telling you that the library has no function that rakes two LED pins as parameters in the way that you tried

You can, however, create more than one NeoPixel object each with its own name and LED pin

Adafruit_NeoPixel pixels1 = Adafruit_NeoPixel(NUMPIXELS, led1Pin, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels2 = Adafruit_NeoPixel(NUMPIXELS, led2Pin, NEO_GRB + NEO_KHZ800);

Then you can control any LED in either by using the name of the required NeoPixel object

UKHeliBob:

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, ledPin, led2Pin, NEO_GRB + NEO_KHZ800);

The error message is telling you that the library has no function that rakes two LED pins as parameters in the way that you tried

You can, however, create more than one NeoPixel object each with its own name and LED pin

Adafruit_NeoPixel pixels1 = Adafruit_NeoPixel(NUMPIXELS, led1Pin, NEO_GRB + NEO_KHZ800);

Adafruit_NeoPixel pixels2 = Adafruit_NeoPixel(NUMPIXELS, led2Pin, NEO_GRB + NEO_KHZ800);




Then you can control any LED in either by using the name of the required NeoPixel object

Sweet! that was quite a simple fix, thanks Bob :slight_smile: