cclazer
Published © GPL3+

Studio Prop Wall LEDs

Lighting up some props and an LED sign (all neopixels). NEED HELP

IntermediateWork in progress484
Studio Prop Wall LEDs

Things used in this project

Hardware components

Adafruit Metro M4
Adafruit Metro M4
×1
Adafruit NeoPixel Digital RGBW LED Strip - White PCB 60 LED/m PRODUCT ID: 2842
×1
Adafruit NeoPixel Digital RGB LED Strip - Black 60 LED - BLACK PRODUCT ID: 1461
×1

Story

Read more

Code

[HELP HERE] COMBINED Version for Metro Board

Arduino
This is the current mess of me trying to follow along what I've found online for running multiple strips from 1 board on different pins. I made an elementary attempt to merge... but need guidance to test a working version.

I'd like to have sword code running on pin 7 - and then be able to follow the corrected version you all help me with to add other items down the road for other props. (once i get a test working anyways, i have a few others ready to try as well)

I've read that I have to remove delays etc, but I believe i'm failing at getting any of the setup right first...
// A basic everyday NeoPixel strip test program.

// NEOPIXEL BEST PRACTICES for most reliable operation:
// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
//   connect GROUND (-) first, then +, then data.
// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
//   a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
// (Skipping these may work OK on your workbench but can fail in the field)

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

// have 2 independent NEO_RGBW

NEO_RGBW leds1[118]
NEO_RGBW leds3[120]

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 120

// Declare our NeoPixel strip object:
Adafruit_NeoPixel led1(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 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)


// setup() function -- runs once at startup --------------------------------

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.
  
  LED_PIN.addLeds<NEO_RGBW, 6>(leds1, 118);
  LED_PIN.addLeds<NEO_RGBW, 7>(leds3, 120);

  leds1.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  leds1.show();            // Turn OFF all pixels ASAP
  leds1.setBrightness(250); // Set BRIGHTNESS to about 1/5 (max = 255)
  
  leds3.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  leds3.show();            // Turn OFF all pixels ASAP
  leds3.setBrightness(255); // Set BRIGHTNESS to about 1/5 (max = 255)
}


// loop() function -- runs repeatedly as long as board is on ---------------

void loop() {  

  // render the first animation into leds1
  animationA();
  
  // render the second animation into leds3
  animationC();

  
  leds1.show();
  leds13.show();
}

void animationA() {
  rainbow(5);             // Flowing rainbow cycle along the whole strip
}


// Some functions of our own for creating animated effects -----------------

// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow(int wait) {
  // Hue of first pixel runs 5 complete loops through the color wheel.
  // Color wheel has a range of 65536 but it's OK if we roll over, so
  // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time
  // means we'll make 5*65536/256 = 1280 passes through this outer loop:
  for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
    for(int i=0; i<leds1.numPixels(); i++) { // For each pixel in strip...
      // Offset pixel hue by an amount to make one full revolution of the
      // color wheel (range of 65536) along the length of the strip
      // (leds1.numPixels() steps):
      int pixelHue = firstPixelHue + (i * 65536L / leds1.numPixels());
      // leds1.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
      // optionally add saturation and value (brightness) (each 0 to 255).
      // Here we're using just the single-argument hue variant. The result
      // is passed through leds1.gamma32() to provide 'truer' colors
      // before assigning to each pixel:
      leds1.setPixelColor(i, leds1.gamma32(leds1.ColorHSV(pixelHue)));
    }
    leds1.show(); // Update strip with new contents
    delay(wait);  // Pause for a moment
    }
  }
  
void animationC() 
{
  float MinBrightness = 0;
  float MaxBrightness = 255 - MinBrightness;
  float SpeedFactor = 0.01;
  float wait = 4;

  for(int b=0;b<65535;b++) 
  {
    float intensity = MaxBrightness/2.0*(1.0+sin(SpeedFactor*b)) + MinBrightness;
    leds3.setBrightness(intensity);
    for (uint8_t i=0;i<strip.numPixels();i++)
    {
      leds3.setPixelColor(i, 0, 200, 255, 0);
    }
    leds3.show();
    delay(wait);
  }
}

Sword Pulse [Works]

Arduino
Code used on the Adafruit Trinkets powered by batteries. (Test codes that I modified to meet my project needs - I'm nowhere near skill level of writing from scratch)

I'm going to route the wiring from the Metro board for these swords past the Trinket boards - so that they can still be removed from my wall and ran independently if needed. So the trinkets won't be used for the project mentioned here.
// NeoPixel test program showing use of the WHITE channel for RGBW
// pixels only (won't look correct on regular RGB NeoPixel strips).

#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?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN     6

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT  120

// NeoPixel brightness, 0 (min) to 255 (max)
#define BRIGHTNESS 255

#define TOTAL_LEDS 120

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 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)

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.

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(255); // Set BRIGHTNESS to about 1/5 (max = 255)
}

void loop() 
{
  float MinBrightness = 0;
  float MaxBrightness = 255 - MinBrightness;
  float SpeedFactor = 0.01;
  float wait = 4;

  for(int b=0;b<65535;b++) 
  {
    float intensity = MaxBrightness/2.0*(1.0+sin(SpeedFactor*b)) + MinBrightness;
    strip.setBrightness(intensity);
    for (uint8_t i=0;i<strip.numPixels();i++)
    {
      strip.setPixelColor(i, 0, 200, 255, 0);
    }
    strip.show();
    delay(wait);
  }
}

Shop Sign - Scrolling Rainbow [Works]

Arduino
Currently set to pin 6 of my Metro board. (Test codes that I modified to meet my project needs - I'm nowhere near skill level of writing from scratch)
// A basic everyday NeoPixel strip test program.

// NEOPIXEL BEST PRACTICES for most reliable operation:
// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
//   connect GROUND (-) first, then +, then data.
// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
//   a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
// (Skipping these may work OK on your workbench but can fail in the field)

#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?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    6

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 120

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 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)


// setup() function -- runs once at startup --------------------------------

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.

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(250); // Set BRIGHTNESS to about 1/5 (max = 255)
}


// loop() function -- runs repeatedly as long as board is on ---------------

void loop() {
  rainbow(5);             // Flowing rainbow cycle along the whole strip
}


// Some functions of our own for creating animated effects -----------------

// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow(int wait) {
  // Hue of first pixel runs 5 complete loops through the color wheel.
  // Color wheel has a range of 65536 but it's OK if we roll over, so
  // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time
  // means we'll make 5*65536/256 = 1280 passes through this outer loop:
  for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
    for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
      // Offset pixel hue by an amount to make one full revolution of the
      // color wheel (range of 65536) along the length of the strip
      // (strip.numPixels() steps):
      int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
      // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
      // optionally add saturation and value (brightness) (each 0 to 255).
      // Here we're using just the single-argument hue variant. The result
      // is passed through strip.gamma32() to provide 'truer' colors
      // before assigning to each pixel:
      strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
    }
    strip.show(); // Update strip with new contents
    delay(wait);  // Pause for a moment
    }
  }

Credits

cclazer
1 project • 0 followers

Comments