New to code PIR with theater chase

I want to use a pir to speed up the theatre chase progressively to a delay of 15 when motion is detected. Initial delay of 155 is when setting is low. Please help me understand this…

#include <Adafruit_NeoPixel.h>
#define PIN 0
#define NUM_LEDS 8
// Parameter 1 = number of pixels in strip
// Parameter 2 = 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)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, 0, NEO_GRB + NEO_KHZ800);

void setup() {
strip.begin();
}

void loop() {
chase(strip.Color(255,220,155)); // Red
/* chase(strip.Color(0, 255, 0)); // Green
chase(strip.Color(0, 0, 255)); // Blue
*/
}

static void chase(uint32_t c) {
for(uint16_t i=0; i<strip.numPixels()+4; i++) {
strip.setBrightness(150);
strip.setPixelColor(i , c); // Draw new pixel
strip.setPixelColor(i-4, 0); // Erase pixel a few steps back
strip.show();
delay(155);

Your code is incomplete and lacking code tags.

Try this

Copy your code here

all of this has been less than helpful

jaklos:
all of this has been less than helpful

Thank you for your feedback!

jaklos:
Please help me understand this...

Part of what you need to understand is that what you posted is not very helpful to us. And helping us makes it more likely that we will be able to help you.

Using code tags makes it much easier for us to load your code into the development environment to see what is going on.

Posting the entire sketch lets us see things that might have escaped your notice.

Let us see the entire sketch. Post it using code tags. Those are 2 of the very common early steps in getting help. For more, take a look at the How to use this forum - please read sticky post at the top of this forum.

thank you

vinceherman:
Part of what you need to understand is that what you posted is not very helpful to us. And helping us makes it more likely that we will be able to help you.

Using code tags makes it much easier for us to load your code into the development environment to see what is going on.

Posting the entire sketch lets us see things that might have escaped your notice.

Let us see the entire sketch. Post it using code tags. Those are 2 of the very common early steps in getting help. For more, take a look at the How to use this forum - please read sticky post at the top of this forum.

#include <Adafruit_NeoPixel.h>
#define PIN 0
#define NUM_LEDS 0
// Parameter 1 = number of pixels in strip
// Parameter 2 = 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)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, 12, NEO_GRB + NEO_KHZ800);

int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
 
void setup() {
  strip.begin();
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
 
  Serial.begin(9600);
}

 
void loop() 
  {
  chase(strip.Color(255,220,155)); // Red
/* chase(strip.Color(0, 255, 0)); // Green
  chase(strip.Color(0, 0, 255)); // Blue
*/

  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
static void chase(uint32_t c) {
  for(uint16_t i=0; i<strip.numPixels()+2; i++) {
      strip.setBrightness(15);
      strip.setPixelColor(i  , c); // Draw new pixel
      strip.setPixelColor(i-2, 0); // Erase pixel a few steps back
      strip.show();
      delay(20);
     }
   }
  }
  }
  }

Without the addition of pir commands the chase works fine. I am getting “exit status 1
‘chase’ was not declared in this scope” how do I rectify this?

You have to either implement that function yourself, or make sure such a function is in one of the #include libraries.

No idea what chase() is supposed to do, but your compiler basically tells you it doesn't exist.

what is weird is that if you delete everything from val to the end it works fine. I am just trying to combine code because I have had zero luck with anyone trying to help me understand this.

Have you tried the IDE's auto-format tool?

You really should.

static void chase(uint32_t c) {
        for (uint16_t i = 0; i < strip.numPixels() + 2; i++) {
          strip.setBrightness(15);
          strip.setPixelColor(i  , c); // Draw new pixel
          strip.setPixelColor(i - 2, 0); // Erase pixel a few steps back
          strip.show();
          delay(20);
        }
      }

You have created/declared this function inside of loop(). It needs to be declared outside of any other function, and loop() is indeed a function.

Right... Sharp eyes! I completely missed it skimming the code, no doubt in part as I don't expect a function there in the first place, and the terrible formatting of the code (OP: use autoformat, it really helps readability).