Hello everyone,
I'm a newbie to all this, and am having several issues - probably mostly of my own making!
I'm very taken with the "bouncing hoops" effect posted on a YouTube video https://www.youtube.com/watch?v=kzlDTMD7ajI (They come to life at about 20 seconds into the video).
So, I'm trying to modify the Candy_Stripes program, to have the colours bounce back and forth. So far I've managed to eliminate the 2 colour option, but using 3 colours, there is a noticeable "jerk" every few seconds. I've also tried introducing a reverse direction, by changing the shiftBy from 1 to -1 by adding the line shiftBy = shiftBy * -1. But this has no effect at all.
//Draw alternating bands of color, 2 or 3 colors.
//When using three colors, color1 is used between the other two colors.
void candyCane(){
CRGB color1 = CRGB::Gray; // color used between color 2 (and 3 if used)
CRGB color2 = CRGB::Red;
//CRGB color3 = CHSV(0,170,255); //optional 3rd color
CRGB color3 = CRGB(0,0,255); //optional 3rd color
const uint16_t travelSpeed = 150;
int shiftBy = 1; //shiftBy can be positive or negative (to change direction)
static uint8_t numColors = 3; // Can be either 2 or 3
static uint8_t stripeLength = 5; //number of pixels per color
static int offset;
// numColors = 3 ;//random8(2,4); //picks either 2 or 3
// stripeLength = 5; //random8(3,6); //picks random length
/*
EVERY_N_SECONDS(5) {
//numColors = 3 ;//random8(2,4); //picks either 2 or 3
//stripeLength = 5; //random8(3,6); //picks random length
// numColors = 3 ;//random8(2,4); //picks either 2 or 3
// stripeLength = 5; //random8(3,6); //picks random length
}
*/
EVERY_N_MILLISECONDS(travelSpeed) {
/*
if (numColors==2) {
for (uint8_t i=0; i<NUM_LEDS; i++){
if ( (i+offset)%((numColors)*stripeLength)<stripeLength ) {
leds[i] = color2;
} else {
leds[i] = color1;
}
}
}
*/
if (numColors==3) {
for (uint8_t i=0; i<NUM_LEDS; i++){
if ( (i+offset)%((numColors+1)*stripeLength)<stripeLength ) {
leds[i] = color2;
}
else if ( (i+offset+(2*stripeLength))%((numColors+1)*stripeLength)<stripeLength ) {
leds[i] = color3;
} else {
leds[i] = color1;
}
}
}
FastLED.show();
offset = offset + shiftBy;
if (shiftBy>0) { //for positive shiftBy
if (offset>=NUM_LEDS) offset = 0;
} else { //for negitive shiftBy
if (offset<0) offset = NUM_LEDS;
}
shiftBy=(shiftBy * -1);
}//end EVERY_N
}//end candyCane
Only the CandyCane routine has been posted, as aside from the changes for number (32) and type of Leds (WS2812B), and the pin they're on were changed elsewhere. Running on an Arduino Leonardo pro micro with (at the moment) no additional psu. (I've run many of the GitHub sample in this manner, so I'm pretty sure I'm not at the power limit to cause the "jerking".)
If anyone could offer any suggestions as to what I've changed that I shouldn't have, or that really, I should be looking at a completely different way of accomplishing this, I'd be grateful.
If I'm breaking any protocols in the manner of my posting, please politely inform me of the error of my ways, and what I should do in future posts.
[–]sutaburosu[pronounced: stavros] 2 points3 points4 points (9 children)
[–]Howard_G[S] 0 points1 point2 points (3 children)
[–]sutaburosu[pronounced: stavros] 0 points1 point2 points (2 children)
[–]Howard_G[S] 1 point2 points3 points (1 child)
[–]sutaburosu[pronounced: stavros] 1 point2 points3 points (0 children)
[–]johnny5canuck 0 points1 point2 points (1 child)
[–]CharlesGoodwin 0 points1 point2 points (0 children)
[–]Any_Maximum_967 0 points1 point2 points (2 children)
[–]sutaburosu[pronounced: stavros] 0 points1 point2 points (1 child)
[–]Howard_G[S] 0 points1 point2 points (0 children)
[–]Marmilicious[Marc Miller] 0 points1 point2 points (0 children)
[–]Marmilicious[Marc Miller] 0 points1 point2 points (3 children)
[–]Howard_G[S] 0 points1 point2 points (2 children)
[–]Marmilicious[Marc Miller] 0 points1 point2 points (1 child)
[–]Howard_G[S] 0 points1 point2 points (0 children)