NeoPixel 1138 RBG strip

I'm trying to use a Neopixel 1138 strip and so far ivr gotten it to turn on how I want and stay on but I can't figure out how to program a flickering effect almost how a lightsaber would. Doesnt have to be anything crazy just a first-time project. here is my code so far.

// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN        2 // On Trinket or Gemma, suggest changing this to 1

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 60 // Popular NeoPixel ring size

// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 50 // Time (in milliseconds) to pause between pixels

void setup() {
  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  // END of Trinket-specific code.

  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  pixels.clear(); // Set all pixel colors to 'off'

  // The first NeoPixel in a strand is #0, second is 1, all the way up
  // to the count of pixels minus one.
  for(int i=0; i<NUMPIXELS; i++) { // For each pixel...

    // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    // Here we're using a moderately bright green color:
    pixels.setPixelColor(i, pixels.Color(0, 45, 255));

    pixels.show();   // Send the updated pixel colors to the hardware.

    delay(DELAYVAL); // Pause before next pass through loop
  }
  
}


void loop() {
  
}

Would you give more detail, or draw pictures of what a light sabre does?

I can describe it better. I got it to turn on and stay on. Now I’m hoping while’s it’s on it will flicker but I’m hoping for it to be a more random flicker and not just blinking every second. I hope that makes sense; just really want them to flicker I just down know how to add that to the programming.

We will get to that soon... but first...

Flicker... like (about) one second on, (about) one second off, or on/off ten times a second? My light sabre does not flicker, so would you pick a picture (GIF) that shows what you are trying? Thank you.

Just some fun thinking...

  1. turn the strip on and the color grows from the handle to the end.
  2. (your flicker or glowing or pulsing)
  3. if the sabre bumps anything, a "knock sensor" causes a one-time "flash"
  4. when it is turned off, the color shrinks from the end to the handle.
  5. maybe a gyro to read "vertical" versus "horizontal" for sound/light

Duplicate topics.

If every pixel has the same color or you have a number of them that are the same you can use

pixels.fill();

to give them the same value rather than iterate through each one at a time.

For example this will turn all on and off and they should fade in and out, decrease the time and you get flicker instead of fade. This way you only modify one rgb value to fill all pixels.

void loop() {
  
  for(int i=1; i<50; i++) {
  pixels.fill(pixels.Color(0,i,0),0,NUMPIXELS);
  pixels.show();
  delay(15);
  }

  for(int i=50; i>1; i--) {
  pixels.fill(pixels.Color(0,i,0),0,NUMPIXELS);
  pixels.show();
  delay(15);
  }
}

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