I am a complete novice and suspect I have bitten of more than I might chew with this so I'd be extremely grateful for any help and direction that might be forthcoming.
I have lifted the core of the code from Hans's article on LEDStrip effects for Arduino and have made very limited progress as I find my way. So far I have made some minor modifications as is evident from the attached code that includes: -
- Two additional strobe functions including and an additional integer that I have called BlackDelay which for the purpose of what I am trying to achieve requires a different value to the FlashDelay.
- Corresponding duplicate function and statement blocks for the additional strobe functions.
What I would like to do is make each Pixel individually addressable with fixed colour/colour combination and strobe sequences, determined by the values entered for each pixel in the respective strobe functions - There are currently 3 strobe functions per pixel.
I have a Mega 2560 connected via pin 6 and a 470 ohm resistor and, a 1000 uf capacitor across the power rails on the breadboard with 5, PL9823 addressable RGB LEDS for testing but will eventually require >100, therefore 100 or so groups of 3 strobe functions. This is where it is getting messy and I'm sure there is a more professional way of going about this?
Not every one of the intended 100 or so Pixels will be unique, as in, some Pixels may share the same colour/colour combination and strobe sequenceI and I am assuming that if there are say 80 combination variants, that these could be configured in setup and then called from a loop function for each Pixel?
The modified code is as follows:
#include <Adafruit_NeoPixel.h> // NeoPixel Library
#define PIN 6 // = pin number
#define NUM_LEDS 5 // = number of pixels in the daisy chain
// Pixel type flags, include as required:
// 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 configured for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels configured for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_RGB + NEO_KHZ800); // Using PL9823 RGB LED (WS2811 drivers)
void setup() {
strip.begin();
strip.show(); // Initialise all pixels to 'off'
}
void loop() {
// Strobe0
Strobe0(0xff, 0xff, 0xff, 5, 100, 500, 5000);
// Strobe1
Strobe1(0x00, 0xff, 0x00, 1, 500, 1000, 3000);
// Strobe2
Strobe2(0xff, 0xff, 0x00, 3, 300, 500, 3000);
}
void Strobe0(byte red, byte green, byte blue, int Strobe0Count, int Flash0Delay, int Black0Delay, int End0Pause){
for(int j = 0; j < Strobe0Count; j++) {
setAll(red,green,blue);
showStrip();
delay(Flash0Delay);
setAll(0,0,0);
showStrip();
delay(Black0Delay);
}
delay(End0Pause);
}
void Strobe1(byte red, byte green, byte blue, int Strobe1Count, int Flash1Delay, int Black1Delay, int End1Pause){
for(int j = 0; j < Strobe1Count; j++) {
setAll(red,green,blue);
showStrip();
delay(Flash1Delay);
setAll(0,0,0);
showStrip();
delay(Black1Delay);
}
delay(End1Pause);
}
void Strobe2(byte red, byte green, byte blue, int Strobe2Count, int Flash2Delay, int Black2Delay, int End2Pause){
for(int j = 0; j < Strobe2Count; j++) {
setAll(red,green,blue);
showStrip();
delay(Flash2Delay);
setAll(0,0,0);
showStrip();
delay(Black2Delay);
}
delay(End2Pause);
}
void showStrip() {
strip.show();
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
I would be extremely grateful for any comments and ideas as to the methodology for this more complicated variant of the original code.