Ok, so needing a bit of help with the coding on this project.
I have 2 current codes that both work as is (both being just modified sample codes):
1. An LED lit sign that runs a scrolling rainbow effect.
2. Plus 2 large resin sword props as you see exampled in the pic. (They pulse a slow fade)
Both codes run great as independent projects. Both are using adafruit neopixel leds. The swords have Trinket boards that are battery powered so that they work in-hand, and the sign is wired to an adafruit metro board.
I'm going to post both independent codes - as well as my in-progress merged version... That's where I need the help. I'd like to run both of of the same metro board while mounted on our wall. I can't for the life of me figure out how to get each code loop to run off of different data pins on the board. (I have a VERY basic knowledge with writing these scripts, very basic) I've tried researching, but seem to get even more lost... If someone could help straighten this out for me I'd GREATLY appreciate it!!!
Hardwiring everything and managing that portion is more so my forte. There I have no issues.
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);
}
}