i hope someone can help me, i'm really new to arduino. I will try to explain what i want to do but my english is pretty poor. I have 6 meters of the digital rgb stripe and use the sample code to make the rainbow cycle along the stripe. what i'm trying to do is to make two color cycles at once each 3 meters. for example led 1 starts with red, led 97 should start with red at the same moment. i hope you understand what i mean.just to rainbowcolor cycles which are synced, each 96 leds long.this is the code i'm using at the moment for the full 192 leds cycle
Code: Select all
#include [color=#006699]"LPD8806.h"[/color]
#include [color=#006699]"SPI.h"[/color]
[color=#7E7E7E]/*****************************************************************************/[/color]
[color=#7E7E7E]// Number of RGB LEDs in strand:[/color]
[color=#CC6600]int[/color] nLEDs = 192;
[color=#7E7E7E]// Chose 2 pins for output; can be any valid output pins:[/color]
[color=#CC6600]int[/color] dataPin = 2;
[color=#CC6600]int[/color] clockPin = 3;
[color=#7E7E7E]// First parameter is the number of LEDs in the strand. The LED strips[/color]
[color=#7E7E7E]// are 32 LEDs per meter but you can extend or cut the strip. Next two[/color]
[color=#7E7E7E]// parameters are SPI data and clock pins:[/color]
LPD8806 strip = LPD8806(nLEDs, dataPin, clockPin);
[color=#7E7E7E]// You can optionally use hardware SPI for faster writes, just leave out[/color]
[color=#7E7E7E]// the data and clock pin parameters. But this does limit use to very[/color]
[color=#7E7E7E]// specific pins on the Arduino. For "classic" Arduinos (Uno, Duemilanove,[/color]
[color=#7E7E7E]// etc.), data = pin 11, clock = pin 13. For Arduino Mega, data = pin 51,[/color]
[color=#7E7E7E]// clock = pin 52. For 32u4 Breakout Board+ and Teensy, data = pin B2,[/color]
[color=#7E7E7E]// clock = pin B1. For Leonardo, this can ONLY be done on the ICSP pins.[/color]
[color=#7E7E7E]//LPD8806 strip = LPD8806(nLEDs);[/color]
[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() {
[color=#7E7E7E]// Start up the LED strip[/color]
strip.[color=#CC6600]begin[/color]();
[color=#7E7E7E]// Update the strip, to start they are all 'off'[/color]
strip.show();
}
[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]() {
rainbowCycle(0); [color=#7E7E7E]// make it go through the cycle fairly fast[/color]
}
[color=#CC6600]void[/color] rainbowCycle(uint8_t wait) {
uint16_t i, j;
[color=#CC6600]for[/color] (j=0; j < 384; j++) { [color=#7E7E7E]// 5 cycles of all 384 colors in the wheel[/color]
[color=#CC6600]for[/color] (i=0; i < strip.numPixels(); i++) {
[color=#7E7E7E]// tricky math! we use each pixel as a fraction of the full 384-color wheel[/color]
[color=#7E7E7E]// (thats the i / strip.numPixels() part)[/color]
[color=#7E7E7E]// Then add in j which makes the colors go around per pixel[/color]
[color=#7E7E7E]// the % 384 is to make the wheel cycle around[/color]
strip.setPixelColor(i, Wheel( ((i * 384 / strip.numPixels()) + j) % 384) );
}
strip.show(); [color=#7E7E7E]// write all the pixels out[/color]
[color=#CC6600]delay[/color](wait);
}
}
[color=#7E7E7E]/* Helper functions */[/color]
[color=#7E7E7E]//Input a value 0 to 384 to get a color value.[/color]
[color=#7E7E7E]//The colours are a transition r - g -b - back to r[/color]
uint32_t Wheel(uint16_t WheelPos)
{
[color=#CC6600]byte[/color] r, g, b;
[color=#CC6600]switch[/color](WheelPos / 128)
{
[color=#CC6600]case[/color] 0:
r = 127 - WheelPos % 128; [color=#7E7E7E]//Red down[/color]
g = WheelPos % 128; [color=#7E7E7E]// Green up[/color]
b = 0; [color=#7E7E7E]//blue off[/color]
[color=#CC6600]break[/color];
[color=#CC6600]case[/color] 1:
g = 127 - WheelPos % 128; [color=#7E7E7E]//green down[/color]
b = WheelPos % 128; [color=#7E7E7E]//blue up[/color]
r = 0; [color=#7E7E7E]//red off[/color]
[color=#CC6600]break[/color];
[color=#CC6600]case[/color] 2:
b = 127 - WheelPos % 128; [color=#7E7E7E]//blue down [/color]
r = WheelPos % 128; [color=#7E7E7E]//red up[/color]
g = 0; [color=#7E7E7E]//green off[/color]
[color=#CC6600]break[/color];
}
[color=#CC6600]return[/color](strip.Color(r,g,b));
}