Components and supplies
Adafruit Metro M4
Adafruit NeoPixel Digital RGBW LED Strip - White PCB 60 LED/m PRODUCT ID: 2842
Adafruit NeoPixel Digital RGB LED Strip - Black 60 LED - BLACK PRODUCT ID: 1461
Project description
Code
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.
1// NeoPixel test program showing use of the WHITE channel for RGBW 2// pixels only (won't look correct on regular RGB NeoPixel strips). 3 4#include <Adafruit_NeoPixel.h> 5#ifdef __AVR__ 6 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket 7#endif 8 9// Which pin on the Arduino is connected to the NeoPixels? 10// On a Trinket or Gemma we suggest changing this to 1: 11#define LED_PIN 6 12 13// How many NeoPixels are attached to the Arduino? 14#define LED_COUNT 120 15 16// NeoPixel brightness, 0 (min) to 255 (max) 17#define BRIGHTNESS 255 18 19#define TOTAL_LEDS 120 20 21// Declare our NeoPixel strip object: 22Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800); 23// Argument 1 = Number of pixels in NeoPixel strip 24// Argument 2 = Arduino pin number (most are valid) 25// Argument 3 = Pixel type flags, add together as needed: 26// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 27// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 28// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 29// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 30// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) 31 32void setup() { 33 // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. 34 // Any other board, you can remove this part (but no harm leaving it): 35#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) 36 clock_prescale_set(clock_div_1); 37#endif 38 // END of Trinket-specific code. 39 40 strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) 41 strip.show(); // Turn OFF all pixels ASAP 42 strip.setBrightness(255); // Set BRIGHTNESS to about 1/5 (max = 255) 43} 44 45void loop() 46{ 47 float MinBrightness = 0; 48 float MaxBrightness = 255 - MinBrightness; 49 float SpeedFactor = 0.01; 50 float wait = 4; 51 52 for(int b=0;b<65535;b++) 53 { 54 float intensity = MaxBrightness/2.0*(1.0+sin(SpeedFactor*b)) + MinBrightness; 55 strip.setBrightness(intensity); 56 for (uint8_t i=0;i<strip.numPixels();i++) 57 { 58 strip.setPixelColor(i, 0, 200, 255, 0); 59 } 60 strip.show(); 61 delay(wait); 62 } 63}
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)
1// A basic everyday NeoPixel strip test program. 2 3// NEOPIXEL BEST PRACTICES for most reliable operation: 4// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections. 5// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. 6// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR. 7// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS 8// connect GROUND (-) first, then +, then data. 9// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip, 10// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. 11// (Skipping these may work OK on your workbench but can fail in the field) 12 13#include <Adafruit_NeoPixel.h> 14#ifdef __AVR__ 15 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket 16#endif 17 18// Which pin on the Arduino is connected to the NeoPixels? 19// On a Trinket or Gemma we suggest changing this to 1: 20#define LED_PIN 6 21 22// How many NeoPixels are attached to the Arduino? 23#define LED_COUNT 120 24 25// Declare our NeoPixel strip object: 26Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); 27// Argument 1 = Number of pixels in NeoPixel strip 28// Argument 2 = Arduino pin number (most are valid) 29// Argument 3 = Pixel type flags, add together as needed: 30// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 31// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 32// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 33// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 34// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) 35 36 37// setup() function -- runs once at startup -------------------------------- 38 39void setup() { 40 // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. 41 // Any other board, you can remove this part (but no harm leaving it): 42#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) 43 clock_prescale_set(clock_div_1); 44#endif 45 // END of Trinket-specific code. 46 47 strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) 48 strip.show(); // Turn OFF all pixels ASAP 49 strip.setBrightness(250); // Set BRIGHTNESS to about 1/5 (max = 255) 50} 51 52 53// loop() function -- runs repeatedly as long as board is on --------------- 54 55void loop() { 56 rainbow(5); // Flowing rainbow cycle along the whole strip 57} 58 59 60// Some functions of our own for creating animated effects ----------------- 61 62// Rainbow cycle along whole strip. Pass delay time (in ms) between frames. 63void rainbow(int wait) { 64 // Hue of first pixel runs 5 complete loops through the color wheel. 65 // Color wheel has a range of 65536 but it's OK if we roll over, so 66 // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time 67 // means we'll make 5*65536/256 = 1280 passes through this outer loop: 68 for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { 69 for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip... 70 // Offset pixel hue by an amount to make one full revolution of the 71 // color wheel (range of 65536) along the length of the strip 72 // (strip.numPixels() steps): 73 int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels()); 74 // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or 75 // optionally add saturation and value (brightness) (each 0 to 255). 76 // Here we're using just the single-argument hue variant. The result 77 // is passed through strip.gamma32() to provide 'truer' colors 78 // before assigning to each pixel: 79 strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue))); 80 } 81 strip.show(); // Update strip with new contents 82 delay(wait); // Pause for a moment 83 } 84 } 85
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.
1// NeoPixel test program showing use of the WHITE channel for RGBW 2// pixels only (won't look correct on regular RGB NeoPixel strips). 3 4#include <Adafruit_NeoPixel.h> 5#ifdef __AVR__ 6 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket 7#endif 8 9// Which pin on the Arduino is connected to the NeoPixels? 10// On a Trinket or Gemma we suggest changing this to 1: 11#define LED_PIN 6 12 13// How many NeoPixels are attached to the Arduino? 14#define LED_COUNT 120 15 16// NeoPixel brightness, 0 (min) to 255 (max) 17#define BRIGHTNESS 255 18 19#define TOTAL_LEDS 120 20 21// Declare our NeoPixel strip object: 22Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800); 23// Argument 1 = Number of pixels in NeoPixel strip 24// Argument 2 = Arduino pin number (most are valid) 25// Argument 3 = Pixel type flags, add together as needed: 26// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 27// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 28// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 29// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 30// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) 31 32void setup() { 33 // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. 34 // Any other board, you can remove this part (but no harm leaving it): 35#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) 36 clock_prescale_set(clock_div_1); 37#endif 38 // END of Trinket-specific code. 39 40 strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) 41 strip.show(); // Turn OFF all pixels ASAP 42 strip.setBrightness(255); // Set BRIGHTNESS to about 1/5 (max = 255) 43} 44 45void loop() 46{ 47 float MinBrightness = 0; 48 float MaxBrightness = 255 - MinBrightness; 49 float SpeedFactor = 0.01; 50 float wait = 4; 51 52 for(int b=0;b<65535;b++) 53 { 54 float intensity = MaxBrightness/2.0*(1.0+sin(SpeedFactor*b)) + MinBrightness; 55 strip.setBrightness(intensity); 56 for (uint8_t i=0;i<strip.numPixels();i++) 57 { 58 strip.setPixelColor(i, 0, 200, 255, 0); 59 } 60 strip.show(); 61 delay(wait); 62 } 63}
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)
1// A basic everyday NeoPixel strip test program. 2 3// NEOPIXEL BEST PRACTICES for most reliable operation: 4// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections. 5// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. 6// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR. 7// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS 8// connect GROUND (-) first, then +, then data. 9// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip, 10// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. 11// (Skipping these may work OK on your workbench but can fail in the field) 12 13#include <Adafruit_NeoPixel.h> 14#ifdef __AVR__ 15 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket 16#endif 17 18// Which pin on the Arduino is connected to the NeoPixels? 19// On a Trinket or Gemma we suggest changing this to 1: 20#define LED_PIN 6 21 22// How many NeoPixels are attached to the Arduino? 23#define LED_COUNT 120 24 25// Declare our NeoPixel strip object: 26Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); 27// Argument 1 = Number of pixels in NeoPixel strip 28// Argument 2 = Arduino pin number (most are valid) 29// Argument 3 = Pixel type flags, add together as needed: 30// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 31// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 32// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 33// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 34// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) 35 36 37// setup() function -- runs once at startup -------------------------------- 38 39void setup() { 40 // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. 41 // Any other board, you can remove this part (but no harm leaving it): 42#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) 43 clock_prescale_set(clock_div_1); 44#endif 45 // END of Trinket-specific code. 46 47 strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) 48 strip.show(); // Turn OFF all pixels ASAP 49 strip.setBrightness(250); // Set BRIGHTNESS to about 1/5 (max = 255) 50} 51 52 53// loop() function -- runs repeatedly as long as board is on --------------- 54 55void loop() { 56 rainbow(5); // Flowing rainbow cycle along the whole strip 57} 58 59 60// Some functions of our own for creating animated effects ----------------- 61 62// Rainbow cycle along whole strip. Pass delay time (in ms) between frames. 63void rainbow(int wait) { 64 // Hue of first pixel runs 5 complete loops through the color wheel. 65 // Color wheel has a range of 65536 but it's OK if we roll over, so 66 // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time 67 // means we'll make 5*65536/256 = 1280 passes through this outer loop: 68 for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { 69 for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip... 70 // Offset pixel hue by an amount to make one full revolution of the 71 // color wheel (range of 65536) along the length of the strip 72 // (strip.numPixels() steps): 73 int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels()); 74 // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or 75 // optionally add saturation and value (brightness) (each 0 to 255). 76 // Here we're using just the single-argument hue variant. The result 77 // is passed through strip.gamma32() to provide 'truer' colors 78 // before assigning to each pixel: 79 strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue))); 80 } 81 strip.show(); // Update strip with new contents 82 delay(wait); // Pause for a moment 83 } 84 } 85
[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...
1// A basic everyday NeoPixel strip test program. 2 3// NEOPIXEL BEST PRACTICES for most reliable operation: 4// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections. 5// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. 6// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR. 7// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS 8// connect GROUND (-) first, then +, then data. 9// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip, 10// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. 11// (Skipping these may work OK on your workbench but can fail in the field) 12 13#include <Adafruit_NeoPixel.h> 14#ifdef __AVR__ 15 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket 16#endif 17 18// have 2 independent NEO_RGBW 19 20NEO_RGBW leds1[118] 21NEO_RGBW leds3[120] 22 23// Which pin on the Arduino is connected to the NeoPixels? 24// On a Trinket or Gemma we suggest changing this to 1: 25#define LED_PIN 26 27// How many NeoPixels are attached to the Arduino? 28#define LED_COUNT 120 29 30// Declare our NeoPixel strip object: 31Adafruit_NeoPixel led1(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); 32// Argument 1 = Number of pixels in NeoPixel strip 33// Argument 2 = Arduino pin number (most are valid) 34// Argument 3 = Pixel type flags, add together as needed: 35// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 36// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 37// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 38// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 39// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) 40 41 42// setup() function -- runs once at startup -------------------------------- 43 44void setup() { 45 // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. 46 // Any other board, you can remove this part (but no harm leaving it): 47#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) 48 clock_prescale_set(clock_div_1); 49#endif 50 // END of Trinket-specific code. 51 52 LED_PIN.addLeds<NEO_RGBW, 6>(leds1, 118); 53 LED_PIN.addLeds<NEO_RGBW, 7>(leds3, 120); 54 55 leds1.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) 56 leds1.show(); // Turn OFF all pixels ASAP 57 leds1.setBrightness(250); // Set BRIGHTNESS to about 1/5 (max = 255) 58 59 leds3.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) 60 leds3.show(); // Turn OFF all pixels ASAP 61 leds3.setBrightness(255); // Set BRIGHTNESS to about 1/5 (max = 255) 62} 63 64 65// loop() function -- runs repeatedly as long as board is on --------------- 66 67void loop() { 68 69 // render the first animation into leds1 70 animationA(); 71 72 // render the second animation into leds3 73 animationC(); 74 75 76 leds1.show(); 77 leds13.show(); 78} 79 80void animationA() { 81 rainbow(5); // Flowing rainbow cycle along the whole strip 82} 83 84 85// Some functions of our own for creating animated effects ----------------- 86 87// Rainbow cycle along whole strip. Pass delay time (in ms) between frames. 88void rainbow(int wait) { 89 // Hue of first pixel runs 5 complete loops through the color wheel. 90 // Color wheel has a range of 65536 but it's OK if we roll over, so 91 // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time 92 // means we'll make 5*65536/256 = 1280 passes through this outer loop: 93 for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { 94 for(int i=0; i<leds1.numPixels(); i++) { // For each pixel in strip... 95 // Offset pixel hue by an amount to make one full revolution of the 96 // color wheel (range of 65536) along the length of the strip 97 // (leds1.numPixels() steps): 98 int pixelHue = firstPixelHue + (i * 65536L / leds1.numPixels()); 99 // leds1.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or 100 // optionally add saturation and value (brightness) (each 0 to 255). 101 // Here we're using just the single-argument hue variant. The result 102 // is passed through leds1.gamma32() to provide 'truer' colors 103 // before assigning to each pixel: 104 leds1.setPixelColor(i, leds1.gamma32(leds1.ColorHSV(pixelHue))); 105 } 106 leds1.show(); // Update strip with new contents 107 delay(wait); // Pause for a moment 108 } 109 } 110 111void animationC() 112{ 113 float MinBrightness = 0; 114 float MaxBrightness = 255 - MinBrightness; 115 float SpeedFactor = 0.01; 116 float wait = 4; 117 118 for(int b=0;b<65535;b++) 119 { 120 float intensity = MaxBrightness/2.0*(1.0+sin(SpeedFactor*b)) + MinBrightness; 121 leds3.setBrightness(intensity); 122 for (uint8_t i=0;i<strip.numPixels();i++) 123 { 124 leds3.setPixelColor(i, 0, 200, 255, 0); 125 } 126 leds3.show(); 127 delay(wait); 128 } 129}
Comments
Only logged in users can leave comments