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!



FastLED Light effec...
 
Share:
Notifications
Clear all

[Solved] FastLED Light effects for Power Rangers

67 Posts
2 Users
1 Reactions
2,669 Views
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

Hi folks,

as you might know, Im not a coder. And because I only use Arduino for some of my scale model projects, I just get lost everytime I start coding again.

So, thats why I don´t know where to start and Im stuck on "easy" tasks.

Im not just a Trekkie but also a big classic Power Rangers Fan. So I bought a Hasbro Lightning Collection Power Morpher to change the toy like electronics and make it my own.
The toy has a coin recognition (the coins have nodges which press buttons). So depending on which buttons are pressed, the light has different colors. I would like to keep this idea, so I can keep the micro-switches.

I want to use a WS2812 ring for the light and as an animation I had a rotating color gradient in mind, maybe with some white sparkling.

To start simple, I was thinking about something like: Button1 pressed = red_gradient, Button2 pressed = blue_gradient, Button1 AND Button2 pressed = green_gradient

That is the way the toy already works.

My first poor attempt is just a code I found online which I tried to customize.

#include <FastLED.h>

#define NUM_LEDS 48
#define buttonPin1 5
#define buttonPin2 3

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds < NEOPIXEL, PB1 > (leds, NUM_LEDS);
  pinMode(buttonPin1, INPUT_PULLUP);
  pinMode(buttonPin2, INPUT_PULLUP);

}

void loop() {

  if (digitalRead(buttonPin1) == LOW) {

    CRGB pattern[] = {
      CRGB(255, 255, 255),
      CRGB(255, 255, 255),
      CRGB(255, 0, 0),
      CRGB(255, 0, 0),

    };
    size_t pattern_sz = sizeof(pattern) / sizeof( * pattern);

    // a 8.8 fixed point position (so 256 = 1.0, 512 = 2.0, 65535 = 255.996)
    static uint16_t basepos = 0;
    // a copy of basepos to be modified over the length of the strip
    uint16_t ledpos = basepos;
    for (uint8_t ledno = 0; ledno < NUM_LEDS; ledno++) {
      // find the integer and fractional parts for this LED 
      uint8_t intpos = ledpos >> 8;
      uint8_t fracpos = ledpos & 0xff;
      // select the two colours to be blended for this LED
      CRGB colA = pattern[intpos % pattern_sz];
      CRGB colB = pattern[(intpos + 1) % pattern_sz];
      // fade colA towards colB by the fractional position
      leds[ledno] = fadeTowardColor(colA, colB, fracpos);
      // move along the source pattern by some fraction of a pixel
      ledpos -= 128;
    }
    FastLED.show();
    delay(10);
    // move the base position by some fractional amount
    basepos += beatsin8(5, 1, 128);

  }

  if (digitalRead(buttonPin2) == LOW) {

    CRGB pattern[] = {
      CRGB(255, 255, 255),
      CRGB(255, 255, 255),
      CRGB(0, 0, 255),
      CRGB(0, 0, 255),

    };
    size_t pattern_sz = sizeof(pattern) / sizeof( * pattern);

    // a 8.8 fixed point position (so 256 = 1.0, 512 = 2.0, 65535 = 255.996)
    static uint16_t basepos = 0;
    // a copy of basepos to be modified over the length of the strip
    uint16_t ledpos = basepos;
    for (uint8_t ledno = 0; ledno < NUM_LEDS; ledno++) {
      // find the integer and fractional parts for this LED 
      uint8_t intpos = ledpos >> 8;
      uint8_t fracpos = ledpos & 0xff;
      // select the two colours to be blended for this LED
      CRGB colA = pattern[intpos % pattern_sz];
      CRGB colB = pattern[(intpos + 1) % pattern_sz];
      // fade colA towards colB by the fractional position
      leds[ledno] = fadeTowardColor(colA, colB, fracpos);
      // move along the source pattern by some fraction of a pixel
      ledpos -= 128;
    }
    FastLED.show();
    delay(10);
    // move the base position by some fractional amount
    basepos += beatsin8(5, 1, 128);
  }

  if (digitalRead(buttonPin1 == LOW) && (buttonPin2 == LOW)) {

    CRGB pattern[] = {
      CRGB(255, 255, 255),
      CRGB(255, 255, 255),
      CRGB(0, 255, 0),
      CRGB(0, 255, 0),

    };
    size_t pattern_sz = sizeof(pattern) / sizeof( * pattern);

    // a 8.8 fixed point position (so 256 = 1.0, 512 = 2.0, 65535 = 255.996)
    static uint16_t basepos = 0;
    // a copy of basepos to be modified over the length of the strip
    uint16_t ledpos = basepos;
    for (uint8_t ledno = 0; ledno < NUM_LEDS; ledno++) {
      // find the integer and fractional parts for this LED 
      uint8_t intpos = ledpos >> 8;
      uint8_t fracpos = ledpos & 0xff;
      // select the two colours to be blended for this LED
      CRGB colA = pattern[intpos % pattern_sz];
      CRGB colB = pattern[(intpos + 1) % pattern_sz];
      // fade colA towards colB by the fractional position
      leds[ledno] = fadeTowardColor(colA, colB, fracpos);
      // move along the source pattern by some fraction of a pixel
      ledpos -= 128;
    }
    FastLED.show();
    delay(10);
    // move the base position by some fractional amount
    basepos += beatsin8(5, 1, 128);
  }
}

// Mark Kriegsman's fadeTowardColor from:
//  https://gist.github.com/kriegsman/d0a5ed3c8f38c64adcb4837dafb6e690 

// Helper function that blends one uint8_t toward another by a given amount
void nblendU8TowardU8(uint8_t & cur,
  const uint8_t target, uint8_t amount) {
  if (cur == target) return;

  if (cur < target) {
    uint8_t delta = target - cur;
    delta = scale8_video(delta, amount);
    cur += delta;
  } else {
    uint8_t delta = cur - target;
    delta = scale8_video(delta, amount);
    cur -= delta;
  }
}

// Blend one CRGB color toward another CRGB color by a given amount.
// Blending is linear, and done in the RGB color space.
// This function modifies 'cur' in place.
CRGB fadeTowardColor(CRGB & cur,
  const CRGB & target, uint8_t amount) {
  nblendU8TowardU8(cur.red, target.red, amount);
  nblendU8TowardU8(cur.green, target.green, amount);
  nblendU8TowardU8(cur.blue, target.blue, amount);
  return cur;
}

 

c


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

Hello everyone, hello Hans,

hopefully after some technical problems, this topic works now.

Where do I begin? Well, who knows Power Rangers? Yes, the 90s series. And who had wished to be a Power Ranger?? Yes, me too.

So, my plan is to modify the Hasbro Lightning Collection Power Morpher. Because the sound is not that great and light effects are also just ok.

I want to use Arduino, DFPlayer and a WS2812 strip and FastLED of course.

The morpher has a build in coin recognition, just 3 buttons, depending on the knobs at the backside of the coins, some of the buttons get pushed and the morpher knows which coin is inserted, so the sound and LED animation fits the coin.

I would like to keep this function and use those buttons (re-wiring). There is also one button which gets pushed when the morpher is open and another button, when you press the activation button.

My idea is to insert a coin, have a LED animation and a MP3 file gets played, to give a feedback, which button is inserted. Then you press the open button, which gives an opening sound, then some background energy hum sound with a nice LED animation. Then you press the activation button which plays the Power Rangers Theme (for example) and stops when your press the button again. When you close the morpher, the open button gets released and that stops the background sound and LED animation and maybe gives a closing sound. Releasing the coin could also give a sound.
Also there could be some "hidden" sound and LED effects, like when you open the morpher without a coin. Or pushing the activation button without letting the morpher open.

Depending on the inserted coin, the color of the LED animation is different. To have an overview, I have made a chart where you can see all functions. I try to paste it here.

I have already made some code, which I can upload another day. The goal is to combine everything, with all those different button presses, and I also don´t know yet, how to store different colors within the same animation and selecting them depending on the pressed coin buttons. Maybe switch case? To implementing sound should not be a big problem, cause I already did that within existing codes.


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

Here is one code as an example. This is made for the "Coin insert" .

I wrote some notes inside it to understand what I mean with Coin_buttons and so on. This code is written just for testing, that´s why there is only one button defined and only one mp3 file and only one color.

#define FASTLED_INTERNAL  // just used to mute the Pragma messages when compiling
#include "FastLED.h"
#include <EEPROM.h>
#define NUM_LEDS 26
CRGB leds[NUM_LEDS];
#define PIN 6
const int Coin_button_Pin = 3;  // the number of the pushbutton pin
int buttonState = 0;            // variable for reading the pushbutton status



//=============== DFPlayer mini ===============//
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11);  // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);


void setup() {
  FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(30);
  pinMode(Coin_button_Pin, INPUT_PULLUP);

  //=============== DFPlayer mini setup ===============//
  mySoftwareSerial.begin(9600);
  Serial.begin(115200);
  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    while (true)
      ;
  }
  myDFPlayer.setTimeOut(500);  //Set serial communictaion time out 500ms
  myDFPlayer.volume(5);        //Set volume value (0~30).
  myDFPlayer.EQ(DFPLAYER_EQ_BASS);
  myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);
}


void loop() {

  buttonState = digitalRead(Coin_button_Pin);  // read the state of the pushbutton value
  if (buttonState == LOW) {                    // this is just an example with one button
                                               // needs to be a 3 button combination function
                                               // example:
                                               // Coin_button_Pin1 pressed                       -> InsertCoin (violett color, violett mp3)
                                               // Coin_button_Pin2 pressed                       -> InsertCoin (pink color, pink mp3)
                                               // Coin_button_Pin1 AND Coin_button_Pin2 pressed  -> InsertCoin (yellow color, yellow mp3)


    InsertCoin(0xff, 0x00, 0x00, 1, 50, 100);  // NewKitt Animation from tweaking4all.com - LED Strip Effects
  }
}

void InsertCoin(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {

  delay(1000);                   // wait 1 second after coin is inserted
  myDFPlayer.playMp3Folder(10);  // play Coin Voice - just example, play Coin Voice should be depending on Coin_Button press
  OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  setAll(0, 0, 0);  // reset all LEDs to black (off)
}

void CenterToOutside(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = ((NUM_LEDS - EyeSize) / 2); i >= 0; i--) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    showStrip();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void OutsideToCenter(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = 0; i <= ((NUM_LEDS - EyeSize) / 2); i++) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    showStrip();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
  // NeoPixel
  strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
  // FastLED
  FastLED.show();
#endif
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
  // NeoPixel
  strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
  // FastLED
  leds[Pixel].r = red;
  leds[Pixel].g = green;
  leds[Pixel].b = blue;
#endif
}

void setAll(byte red, byte green, byte blue) {
  for (int i = 0; i < NUM_LEDS; i++) {
    setPixel(i, red, green, blue);
  }
  showStrip();
}

 


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

<-- I hope this is visible, cause I see just a blank reply.


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

Posted by: @trace

Here is one code as an example. This is made for the "Coin insert" .

I wrote some notes inside it to understand what I mean with Coin_buttons and so on. This code is written just for testing, that´s why there is only one button defined and only one mp3 file and only one color.

#define FASTLED_INTERNAL  // just used to mute the Pragma messages when compiling
#include "FastLED.h"
#include <EEPROM.h>
#define NUM_LEDS 26
CRGB leds[NUM_LEDS];
#define PIN 6
const int Coin_button_Pin = 3;  // the number of the pushbutton pin
int buttonState = 0;            // variable for reading the pushbutton status



//=============== DFPlayer mini ===============//
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11);  // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);


void setup() {
  FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(30);
  pinMode(Coin_button_Pin, INPUT_PULLUP);

  //=============== DFPlayer mini setup ===============//
  mySoftwareSerial.begin(9600);
  Serial.begin(115200);
  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    while (true)
      ;
  }
  myDFPlayer.setTimeOut(500);  //Set serial communictaion time out 500ms
  myDFPlayer.volume(5);        //Set volume value (0~30).
  myDFPlayer.EQ(DFPLAYER_EQ_BASS);
  myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);
}


void loop() {

  buttonState = digitalRead(Coin_button_Pin);  // read the state of the pushbutton value
  if (buttonState == LOW) {                    // this is just an example with one button
                                               // needs to be a 3 button combination function
                                               // example:
                                               // Coin_button_Pin1 pressed                       -> InsertCoin (violett color, violett mp3)
                                               // Coin_button_Pin2 pressed                       -> InsertCoin (pink color, pink mp3)
                                               // Coin_button_Pin1 AND Coin_button_Pin2 pressed  -> InsertCoin (yellow color, yellow mp3)


    InsertCoin(0xff, 0x00, 0x00, 1, 50, 100);  // NewKitt Animation from tweaking4all.com - LED Strip Effects
  }
}

void InsertCoin(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {

  delay(1000);                   // wait 1 second after coin is inserted
  myDFPlayer.playMp3Folder(10);  // play Coin Voice - just example, play Coin Voice should be depending on Coin_Button press
  OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  setAll(0, 0, 0);  // reset all LEDs to black (off)
}

void CenterToOutside(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = ((NUM_LEDS - EyeSize) / 2); i >= 0; i--) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    showStrip();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void OutsideToCenter(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = 0; i <= ((NUM_LEDS - EyeSize) / 2); i++) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    showStrip();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
  // NeoPixel
  strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
  // FastLED
  FastLED.show();
#endif
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
  // NeoPixel
  strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
  // FastLED
  leds[Pixel].r = red;
  leds[Pixel].g = green;
  leds[Pixel].b = blue;
#endif
}

void setAll(byte red, byte green, byte blue) {
  for (int i = 0; i < NUM_LEDS; i++) {
    setPixel(i, red, green, blue);
  }
  showStrip();
}

 

 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2728
 

I'm seeing some interesting posts here haha ... can you reply to this one to see if it works? (I can remove the test post later)


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

@hans So, hopefully this works. Shall I try to post something else again? Or is this reply enough?


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

Posted by: @trace

Here is one code as an example. This is made for the "Coin insert" .

I wrote some notes inside it to understand what I mean with Coin_buttons and so on. This code is written just for testing, that´s why there is only one button defined and only one mp3 file and only one color.

#define FASTLED_INTERNAL  // just used to mute the Pragma messages when compiling
#include "FastLED.h"
#include <EEPROM.h>
#define NUM_LEDS 26
CRGB leds[NUM_LEDS];
#define PIN 6
const int Coin_button_Pin = 3;  // the number of the pushbutton pin
int buttonState = 0;            // variable for reading the pushbutton status



//=============== DFPlayer mini ===============//
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11);  // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);


void setup() {
  FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(30);
  pinMode(Coin_button_Pin, INPUT_PULLUP);

  //=============== DFPlayer mini setup ===============//
  mySoftwareSerial.begin(9600);
  Serial.begin(115200);
  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    while (true)
      ;
  }
  myDFPlayer.setTimeOut(500);  //Set serial communictaion time out 500ms
  myDFPlayer.volume(5);        //Set volume value (0~30).
  myDFPlayer.EQ(DFPLAYER_EQ_BASS);
  myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);
}


void loop() {

  buttonState = digitalRead(Coin_button_Pin);  // read the state of the pushbutton value
  if (buttonState == LOW) {                    // this is just an example with one button
                                               // needs to be a 3 button combination function
                                               // example:
                                               // Coin_button_Pin1 pressed                       -> InsertCoin (violett color, violett mp3)
                                               // Coin_button_Pin2 pressed                       -> InsertCoin (pink color, pink mp3)
                                               // Coin_button_Pin1 AND Coin_button_Pin2 pressed  -> InsertCoin (yellow color, yellow mp3)


    InsertCoin(0xff, 0x00, 0x00, 1, 50, 100);  // NewKitt Animation from tweaking4all.com - LED Strip Effects
  }
}

void InsertCoin(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {

  delay(1000);                   // wait 1 second after coin is inserted
  myDFPlayer.playMp3Folder(10);  // play Coin Voice - just example, play Coin Voice should be depending on Coin_Button press
  OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
  setAll(0, 0, 0);  // reset all LEDs to black (off)
}

void CenterToOutside(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = ((NUM_LEDS - EyeSize) / 2); i >= 0; i--) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    showStrip();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void OutsideToCenter(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
  for (int i = 0; i <= ((NUM_LEDS - EyeSize) / 2); i++) {
    setAll(0, 0, 0);

    setPixel(i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(i + j, red, green, blue);
    }
    setPixel(i + EyeSize + 1, red / 10, green / 10, blue / 10);

    setPixel(NUM_LEDS - i, red / 10, green / 10, blue / 10);
    for (int j = 1; j <= EyeSize; j++) {
      setPixel(NUM_LEDS - i - j, red, green, blue);
    }
    setPixel(NUM_LEDS - i - EyeSize - 1, red / 10, green / 10, blue / 10);

    showStrip();
    delay(SpeedDelay);
  }
  delay(ReturnDelay);
}

void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
  // NeoPixel
  strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
  // FastLED
  FastLED.show();
#endif
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
  // NeoPixel
  strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
  // FastLED
  leds[Pixel].r = red;
  leds[Pixel].g = green;
  leds[Pixel].b = blue;
#endif
}

void setAll(byte red, byte green, byte blue) {
  for (int i = 0; i < NUM_LEDS; i++) {
    setPixel(i, red, green, blue);
  }
  showStrip();
}

 

 

And here is a quote-reply to my not visible post.

 


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

<-- as you can see, as soon as I hit "quote" to my not visible posting, the full posting is visible as quote, but actually posting it, won´t show it.


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

@hans Hi there Hans, any news about this strange behavior?


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2728
 

Posted by: @trace

@hans Hi there Hans, any news about this strange behavior?

 

Let's see - sorry, in the running around I totally overlooked that you had found a new forum bug 😁 
Does this work? (no need to reply - I'm sure I'll see it here)

 


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

@hans I know you have said "no need to reply" but I want to make clear -> of course your post works, I found out, the bug only happens when you use the "insert code" function. As soon as you use it, the whole post is invisible.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2728
 

@trace been doing some testing and cannot find why it is causing an issue. It seems however related to the code you posted - nothing odd with your code, but it seems to trigger a bug in the forum or something like that.
I've reported this one as well on the WPForo support forum. 😞


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2728
 

p.s. these posts even make my browser freeze (for that tab). OMG that's not good 😜 


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
Topic starter  

@hans Oh no, not another mysterious bug. Slowly but surly you can hire me as a bug finder 🤣 And now that you have mentioned it, sometimes, it freezes Firefox on my side too.


   
ReplyQuote
Page 1 / 5
Share: