Go Down

Topic: WS2812B LED Strip and special pattern. (Read 1 time) previous topic - next topic


Sep 11, 2016, 09:34 am Last Edit: Sep 11, 2016, 09:40 am by Test_Center
I'm trying to get a nice pattern on my WS2812B LED strip. This LED strip is 5m and have 300 LEDs. It is in use as a garden light. What I want to make sounds pretty simple but I can't figure out how to do this.

My idea:
-   the whole LED Strip must have a soft orange "back color"
-   there must be some 8 white light spots from +- 15 LEDs
-   this white light spots must be very slowly and smoothly moving across this LED strip.

I have found some code from Andrew Tuline and I have narrow this code down to the part what I need.

Now I have Blue very slowly moving LEDs and the remaining LEDs are black. This slowly moving is exactly what I need. But the moving LEDs must be white and the rmainig Black LEDs must be soft (night) orange.

This is how it looks till now:

I'm using on my table a test strip with 144 LEDs

Is there someone here in this forum who can help me with this?

Here is my code till so far:

Code: [Select]
/* three_sin demo
  By: Andrew Tuline
  Date: March, 2015
  3 sine waves, one for each colour. I didn't take this far.
WAVE for LED Strip.

#include "FastLED.h"                                          // FastLED library. Preferably the latest copy of FastLED 2.1.

#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."

// Fixed definitions cannot change on the fly.
#define LED_DT 4                                              // Serial data pin for WS2812B or WS2801
#define COLOR_ORDER GRB                                       // Are they RGB, GRB or what??
#define LED_TYPE WS2812B                                      // What kind of strip are you using?
#define NUM_LEDS  144                                         // Number of LED's

// Initialize changeable global variables.
uint8_t max_bright = 64;                                      // Overall brightness definition. It can be changed on the fly.

//struct CRGB leds[NUM_LEDS];                                 // Initialize our LED array.
CRGB leds[NUM_LEDS];                                          // Initialize our LED array.

// Initialize global variables for sequences
uint8_t thisdelay = 50;                                       // A delay value for the sequence(s)

int wave1 = 0;

uint8_t inc1 = -500; //-2                                     // Phase shift. Keep it low, as this is the speed at which the waves move.

uint8_t lvl1 = 80;                                            // Any result below this value is displayed as 0.

uint8_t mul1 = 20;                                            // Frequency, thus the distance between waves
uint8_t mul2 = 25;
uint8_t mul3 = 22;

void setup() {
  FastLED.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);        // Use this for WS2812B
  set_max_power_in_volts_and_milliamps(5, 500);               // FastLED Power management set at 5V, 500mA
} // setup()

void loop () {
  EVERY_N_MILLISECONDS(thisdelay) {                           // FastLED based non-blocking delay to update/display the sequence.
    one_sin();                                                // Improved method of using non-blocking delay
} // loop()

void one_sin() {
  wave1 += inc1;
  for (int k = 0; k < NUM_LEDS; k++) {
    leds[k].b = qsub8(sin8(mul3 * k + wave1 / 128), lvl1);    // A fixed frequency, variable phase sine wave with lowered level

    // fill_solid( leds, NUM_LEDS, CHSV(32, 0, 75)); // Filled Background. Orange
    // uint8_t hsvval = qsub8(sin8(mul3*k + wave3/128), lvl3);
    // leds[k] = CHSV(hsvval, 255, 150);
} // one_sin()

void ChangeMe() {
  uint8_t secondHand = (millis() / 1000) % 30;                // Increase this and add more options below if you want a longer demo.
  static uint8_t lastSecond = 99;                             // Static variable, means it's only defined once. This is our 'debounce' variable.

  if (lastSecond != secondHand) {                             // You can change variables, but remember to set them back in the next demo, or they will stay as is.
    lastSecond = secondHand;
    switch (secondHand) {

      case 10: mul1 = 5; mul2 = 8; mul3 = 7; break;

      case 30: break;
} // ChangeMe()


White would be 255,255,255 OR 125,125,125 etc. i.e. all numbers the same value.
Orange, well you will have to experiment.

First load the array with all orange then load the locations in the array with white as needed.
Always load the array in this order so orange turns on the white led that turns off.

No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

Go Up