Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!




trying to get a col...
 
Share:
Notifications
Clear all

trying to get a color chase that looks like this i ahev the ws2812b strip btw thanks


(@owen2132)
Active Member
Joined: 6 months ago
Posts: 5
Topic starter  

 

This topic was modified 6 months ago by owen2132

ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 2018
 

Hi Owen2132,

what exactly are we looking at here?
Did you mean a theatre chase around your keyboard? (you posted a static image, so it is hard to determine what you're looking for)


ReplyQuote
(@owen2132)
Active Member
Joined: 6 months ago
Posts: 5
Topic starter  

@hans im trying to get a led chase on the led lights on the back of my desk the mage there is just what im trying to get it to loook like im using an arduino uno r3 and ws2812b led lights with 60 eds 


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 2018
 

Hi Owen,

You mean something like this theatre chase effect?


ReplyQuote
(@owen2132)
Active Member
Joined: 6 months ago
Posts: 5
Topic starter  

@hanslike that but with more pixels together so like therews only 2 blocks goihjg across at a time with different colors

 


ReplyQuote


 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 2018
 

You'd have to tinker a little with the values in the function.

(below the original function)

In the second, third and last for-loop you could tinker with the value "3" and changing it to (for example) "5" or any other value.
You'd have to experiment a little, but it shouldn't be too hard to change the width 😊 

void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < NUM_LEDS; i=i+3) {
        setPixel(i+q, red, green, blue);    //turn every third pixel on
      }
      showStrip();
     
      delay(SpeedDelay);
     
      for (int i=0; i < NUM_LEDS; i=i+3) {
        setPixel(i+q, 0,0,0);        //turn every third pixel off
      }
    }
  }
}

Now for the color change, you could call the function several times, optionally with a timer, so for example call the function with red, and repeat that for x number of seconds, after that do the same call with a different color, etc.

For example (untested):

void loop() {
  unsigned long startTime = millis(); // register start time
  
  while(millis() - startTime < 5000) // 5000 = 5 seconds
  {
    theaterChase(255, 0, 0, 50); // red
  }
  
  startTime = millis(); // register start time again

  while(millis() - startTime < 5000) // 5000 = 5 seconds
  {
    theaterChase(0, 255, 0, 50); // green
  }
  
  startTime = millis(); // register start time again

  while(millis() - startTime < 5000) // 5000 = 5 seconds
  {
    theaterChase(0, 0, 255, 50); // blue
  }
}

 


ReplyQuote
(@owen2132)
Active Member
Joined: 6 months ago
Posts: 5
Topic starter  

@hansthanks im trying it now


ReplyQuote
(@owen2132)
Active Member
Joined: 6 months ago
Posts: 5
Topic starter  

@hans when i tried it i got these error messages

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"
 
In file included from C:\Users\OwenT\AppData\Local\Temp\arduino_modified_sketch_984165\CD77_Chase_Demo.ino
 
C:\Users\OwenT\Documents\Arduino\libraries\arduino_403904/FastLED.h warning: extra tokens at end of #ifdef directive
 
 #ifdef pixeltypes.h
 
                  ^
 
C:\Users\OwenT\Documents\Arduino\libraries\arduino_403904/FastLED.h note: #pragma message: FastLED version 3.003.003
 
 #    pragma message "FastLED version 3.003.003"
 
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
 
C:\Users\OwenT\AppData\Local\Temp\arduino_modified_sketch_984165\CD77_Chase_Demo.ino: In function 'void theaterChase(byte, byte, byte, int)':
 
CD77_Chase_Demo error: 'setPixel' was not declared in this scope
 
         setPixel(i+q, red, green, blue);    //turn every third pixel on
 
         ^~~~~~~~
 
CD77_Chase_Demo error: 'showStrip' was not declared in this scope
 
       showStrip();
 
       ^~~~~~~~~
 
CD77_Chase_Demo error: 'setPixel' was not declared in this scope
 
         setPixel(i+q, 0,0,0);        //turn every third pixel off
 
         ^~~~~~~~
 
exit status 1
 
'setPixel' was not declared in this scope
 
Invalid library found in C no headers files (.h) found in C:\Users\OwenT\Documents\Arduino\libraries\FastLED
 
 
 
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

 


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 2018
 

Hi Owen,

By the looks of it, you forgot to use the "framework" I defined in the original article (link).
In this framework I've defined some generic functions so the effects work with FastLED and NeoPixel.

It looks like you're using FastLED, but unfortunately, I do not know what the rest of your code looks like.

You could write it the FastLED way. Since I do not know what the LED array is called in your code, I'll just guess that you have a line somewhere that says:

CRGB leds[NUM_LEDS];

 

So instead of 

setPixel(i+q, red, green, blue); 

 

you could write the way this works in FastLED:

leds[i+q] = CRGB(red, green, blue); 

 

And replace 

showStrip();

 

With

FastLED.show();

 

The rest of the errors are mere warnings or message, and I'd ignore these for now:

In file included from C:\Users\OwenT\AppData\Local\Temp\arduino_modified_sketch_984165\CD77_Chase_Demo.ino
 
C:\Users\OwenT\Documents\Arduino\libraries\arduino_403904/FastLED.h warning: extra tokens at end of #ifdef directive
 
 #ifdef pixeltypes.h
 
                  ^
 
C:\Users\OwenT\Documents\Arduino\libraries\arduino_403904/FastLED.h note: #pragma message: FastLED version 3.003.003
 
 #    pragma message "FastLED version 3.003.003"
 
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~

 


ReplyQuote

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: