[SOLVED] Xmas Lights

Hello everyone.
I want to make some decorative lights for the Christmas tree, using a ESP8266, an strip of WS2812B neopixels, and of course Blynk. I already have a sketch, which uses a library called WS2812FX, and which shows a successive series of lighting effects. This sketch works automatically, and I would like to be able to use an on / off switch, as well as a brightness dimmer, and a timer.I already have other projects with Blynk, so I know how to use the missing libraries, as well as put the token and my network data. I only need an on / off button, a slider for brightness and a timer.
Can someone help me with my project?
Thanks in advance.

#include <WS2812FX.h>

#define LED_COUNT 12
#define LED_PIN 4

#define TIMER_MS 5000

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);

unsigned long last_change = 0;
unsigned long now = 0;

void setup() {
  ws2812fx.init();
  ws2812fx.setBrightness(255);
  ws2812fx.setSpeed(200);
  ws2812fx.setColor(0x007BFF);
  ws2812fx.setMode(FX_MODE_STATIC);
  ws2812fx.start();
}

void loop() {
  now = millis();

  ws2812fx.service();

  if(now - last_change > TIMER_MS) {
    ws2812fx.setMode((ws2812fx.getMode() + 1) % ws2812fx.getModeCount());
    last_change = now;
  }
}

please format your code properly when posting!

Iā€™m very sorry. How do I do it correctly ?.
Thank you.

```cpp

put your code here

```


#include <WS2812FX.h>

#define LED_COUNT 12
#define LED_PIN 4

#define TIMER_MS 5000

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);

unsigned long last_change = 0;
unsigned long now = 0;

void setup() {
  ws2812fx.init();
  ws2812fx.setBrightness(255);
  ws2812fx.setSpeed(200);
  ws2812fx.setColor(0x007BFF);
  ws2812fx.setMode(FX_MODE_STATIC);
  ws2812fx.start();
}

void loop() {
  now = millis();

  ws2812fx.service();

  if(now - last_change > TIMER_MS) {
    ws2812fx.setMode((ws2812fx.getMode() + 1) % ws2812fx.getModeCount());
    last_change = now;
  }
}


1 Like

above statement somewhat controversial. if you already done projects with blynk, i assume you already have used at least some buttons and display widgets.

we can help you with the project, but what is your actual question? what did you try and where have it failed?

the code you have posted has nothing blynk related, and - although i do not have installed that lib - it seems valid code for me.

1 Like

Strange library youā€™re usingā€¦ try the FastLED lib insteadā€¦
And Iā€™ve already created a stable LED controller for Blynkā€¦ youā€™re welcome to use it as a starting point to create your own patterns on.

1 Like

Thanks for answering.
Yes, I already have other blynk projects working, but not done by me, but by cutting and pasting pieces of code from other people. Iā€™m not good programming, but iā€™m with the hardware,because this is my job,electronics. Hereā€™s the code for Blynk. What I need to know Is like using a switch to turn on and off the animation of the lights, a slider to vary the brightness, and a timer to be able to timing the project.

#include <WS2812FX.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#define LED_COUNT 12
#define LED_PIN 4
#define TIMER_MS 5000
SimpleTimer timer;

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);

unsigned long last_change = 0;
unsigned long now = 0;
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";


void setup() {
  Blynk.begin(auth, "xxxxxxxxx", "xxxxxxxxxx");
  ws2812fx.init();
  ws2812fx.setBrightness(255);
  ws2812fx.setSpeed(200);
  ws2812fx.setColor(0x007BFF);
  ws2812fx.setMode(FX_MODE_STATIC);
  ws2812fx.start();
}

void loop() {
  Blynk.run();
  timer.run();
  
  now = millis();

  ws2812fx.service();

  if(now - last_change > TIMER_MS) {
    ws2812fx.setMode((ws2812fx.getMode() + 1) % ws2812fx.getModeCount());
    last_change = now;
  }
}

Well, I have known this library two days ago, and it seems to work well.It includes the Adafruit Neopixel library. It is from kitesurfer1404,at GitHub.
A few days ago, I found your project, and I wanted to try it out, but I could not clone it. I have two iphones and an android phone, but I have not been able to scan the code. Sometimes it gives me the message,ā€œthis is not a valid QR codeā€, and in others simply Blynk show me ā€œscanningā€, but nothing happens.
What could be the problem?
Thank you.

This is also extreme rubbish. Just use FastLED.

Common issue with old QR codes and mismatched versions.
Recreate the dash yourself without cloning which is actaully better as you have more control.

Hi. At this moment I only need a simple project, that consumes few resources, in order to be able to use it with an ESP8266-01, and that also does not use more than the 2000 units of battery of Blynk. This is going to be a gift for christmas tree lights, that will use one or two strips of leds, depending on the size of the tree, that my daughter will buy. I only need to implement in the sketch I have posted, a switch to turn on and off the sequence of animations, A control for brightness, and a timer to program it. Thatā€™s it.
On the other hand, I am very interested in your project, for all the possibilities it has, but that will be for another project that I have in mind, for later,and surely iā€™ll ask you for help,given the other options, which I would like to add.
Thank you very much.

Hi.
I want to use your project, and I would like to know, if you can solve some doubts I have. The library wifi_credentials, would have to create it in: arduino \ libraries \ wifi_credentials \ wifi_credentials \ wifi_credentials.h?.
Where do I have to put the settings.h file?
Thank You.

Put all the files from the project zip file in the same project folder.

And your credentials file should be in:
arduino \ libraries \ wifi_credentials \ wifi_credentials.h

you have 1 too many folders.

OK, thatā€™s how I imagined it, arduino \ libraries \ wifi_credentials \ wifi_credentials.h, but Iā€™m sorry, I do not quite understand ,how put all the files from the proyect zip file,in the same proyect folder.
Please what do you mean? I do not have much practice with programming, arduino, lbraries, etc.
Nor with English.

Just unzip the entire project in to this folder:

\ Arduino \ ESP8266-WS28xx-Blynk

And then open the INO file. You will see settings.h as a tab in the IDE.

OK,Thanks.

Hello again.
The verify / compile option gives me multiple errors. I am using a NodeMCU V1 module for arduino ide version 1.6.9. The version of the FastLed library is 3.001.005.
I attach the bug report.

Arduino: 1.6.9 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

In file included from D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino:5:0:

D:\Arduino\libraries\FastLED/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.005

 #    pragma message "FastLED version 3.001.005"

                     ^

In file included from D:\Arduino\libraries\FastLED/FastLED.h:65:0,

                 from D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino:5:

D:\Arduino\libraries\FastLED/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output

 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"

                       ^

ESP8266-WS28xx-Blynk:49: error: 'rainbow' was not declared in this scope

 SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle};

                                 ^

ESP8266-WS28xx-Blynk:49: error: 'rainbowWithGlitter' was not declared in this scope

 SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle};

                                          ^

ESP8266-WS28xx-Blynk:49: error: 'confetti' was not declared in this scope

 SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle};

                                                              ^

ESP8266-WS28xx-Blynk:49: error: 'sinelon' was not declared in this scope

 SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle};

                                                                        ^

ESP8266-WS28xx-Blynk:49: error: 'juggle' was not declared in this scope

 SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle};

                                                                                 ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite0(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:59: error: 'updateColours' was not declared in this scope

     updateColours(arrayCurrent[0], param.asInt(), arrayCurrent[2], arrayCurrent[3]);

                                                                                   ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite1(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:65: error: 'updateColours' was not declared in this scope

     updateColours(arrayCurrent[0], arrayCurrent[1], param.asInt(), arrayCurrent[3]);

                                                                                   ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite2(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:71: error: 'updateColours' was not declared in this scope

     updateColours(arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], param.asInt());

                                                                                   ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite3(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:79: error: 'nextPattern' was not declared in this scope

   if (varZone == ZONE || varZone == 1 && param.asInt()) nextPattern();

                                                                     ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite6(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:83: error: 'updateColours' was not declared in this scope

     updateColours(1, 0, 255, 255);

                                 ^

ESP8266-WS28xx-Blynk:84: error: 'updateWidgets' was not declared in this scope

     updateWidgets();

                   ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite7(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:89: error: 'updateColours' was not declared in this scope

     updateColours(1, 80, 255, 255);

                                  ^

ESP8266-WS28xx-Blynk:90: error: 'updateWidgets' was not declared in this scope

     updateWidgets();

                   ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite4(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:95: error: 'updateColours' was not declared in this scope

     updateColours(1, 152, 255, 255);

                                   ^

ESP8266-WS28xx-Blynk:96: error: 'updateWidgets' was not declared in this scope

     updateWidgets();

                   ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite8(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:101: error: 'updateColours' was not declared in this scope

     updateColours(1, 255, 0, 255);

                                 ^

ESP8266-WS28xx-Blynk:102: error: 'updateWidgets' was not declared in this scope

     updateWidgets();

                   ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite10(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:107: error: 'updateColours' was not declared in this scope

     updateColours(param.asInt(), arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]);

                                                                                   ^

ESP8266-WS28xx-Blynk:108: error: 'updateWidgets' was not declared in this scope

     updateWidgets();

                   ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite14(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:123: error: 'updateColours' was not declared in this scope

     updateColours(1, 255, 255, 0);

                                 ^

ESP8266-WS28xx-Blynk:124: error: 'updateWidgets' was not declared in this scope

     updateWidgets();

                   ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite23(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:139: error: 'updateColours' was not declared in this scope

     updateColours(arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]);

                                                                                     ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite25(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:148: error: 'class BlynkWifi' has no member named 'setProperty'

       Blynk.setProperty(vPIN_COLOUR_MEM1, "color", CurrentHexRGB());

             ^

ESP8266-WS28xx-Blynk:150: error: 'updateColours' was not declared in this scope

       updateColours(arrayMemory1[0], arrayMemory1[1], arrayMemory1[2], arrayMemory1[3]);

                                                                                       ^

ESP8266-WS28xx-Blynk:151: error: 'updateWidgets' was not declared in this scope

       updateWidgets();

                     ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite26(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:159: error: 'class BlynkWifi' has no member named 'setProperty'

       Blynk.setProperty(vPIN_COLOUR_MEM2, "color", CurrentHexRGB());

             ^

ESP8266-WS28xx-Blynk:161: error: 'updateColours' was not declared in this scope

       updateColours(arrayMemory2[0], arrayMemory2[1], arrayMemory2[2], arrayMemory2[3]);

                                                                                       ^

ESP8266-WS28xx-Blynk:162: error: 'updateWidgets' was not declared in this scope

       updateWidgets();

                     ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite27(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:170: error: 'class BlynkWifi' has no member named 'setProperty'

       Blynk.setProperty(vPIN_COLOUR_MEM3, "color", CurrentHexRGB());

             ^

ESP8266-WS28xx-Blynk:172: error: 'updateColours' was not declared in this scope

       updateColours(arrayMemory3[0], arrayMemory3[1], arrayMemory3[2], arrayMemory3[3]);

                                                                                       ^

ESP8266-WS28xx-Blynk:173: error: 'updateWidgets' was not declared in this scope

       updateWidgets();

                     ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite24(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:182: error: 'updateColours' was not declared in this scope

     updateColours(2, arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]);

                                                                       ^

ESP8266-WS28xx-Blynk:185: error: 'updateColours' was not declared in this scope

     updateColours(0, arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]);

                                                                       ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void BlynkWidgetWrite29(BlynkReq&, const BlynkParam&)':

ESP8266-WS28xx-Blynk:191: error: 'updateColours' was not declared in this scope

     updateColours(1, 152, 255, 100);

                                   ^

ESP8266-WS28xx-Blynk:192: error: 'updateWidgets' was not declared in this scope

     updateWidgets();

                   ^

ESP8266-WS28xx-Blynk:194: error: 'updateColours' was not declared in this scope

     updateColours(arrayNightMemory[0], arrayNightMemory[1], arrayNightMemory[2], arrayNightMemory[3]);

                                                                                                     ^

ESP8266-WS28xx-Blynk:195: error: 'updateWidgets' was not declared in this scope

     updateWidgets();

                   ^

D:\Arduino\ESP8266-WS28xx-Blynk-master\ESP8266-WS28xx-Blynk\ESP8266-WS28xx-Blynk.ino: In function 'void rainbowWithGlitter()':

ESP8266-WS28xx-Blynk:303: error: 'addGlitter' was not declared in this scope

   addGlitter(80);

                ^

exit status 1
'rainbow' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


This is a great way to start learning :wink:

Start with the easiest to understand

Between reading the error and looking at the carrot pointer, this is basically saying you have a variable ā€˜rainbowā€™ that has not been declared in your pre-setup

e.g.
int rainbow; // declare this variable as capable of containing an integer number value

or
float rainbow; // declare this variable as capable of containing a floating number value

Hi.
The sketch Iā€™m using is not mine, itā€™s from Jamin, and although itā€™s a work in progress, it works fine for him. I want to use it for myself, but except for the auth token and the wifi credentials, I have not modified anything, for Which I do not understand because it does not compile.
To my understanding the problem must be in the version of FastLed, the version of Arduino ide, or in something else.
I have come to this conclusion, because none of the examples that come with the FastLed library, work for me. When I try to load them, a lot of errors appear. I add the error report when I try to load the example " ColorPalette".On the other hand all the examples of the FastLed library work perfectly in an Arduino Nano.".

Any ideas?.
Thank you.

Arduino: 1.6.9 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

In file included from D:\Arduino\libraries\FastLED\examples\ColorPalette\ColorPalette.ino:1:0:

D:\Arduino\libraries\FastLED/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.005

 #    pragma message "FastLED version 3.001.005"

                     ^

In file included from D:\Arduino\libraries\FastLED/FastLED.h:65:0,

                 from D:\Arduino\libraries\FastLED\examples\ColorPalette\ColorPalette.ino:1:

D:\Arduino\libraries\FastLED/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output

 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"

                       ^

D:\Arduino\libraries\FastLED\examples\ColorPalette\ColorPalette.ino: In function 'void loop()':

ColorPalette:50: error: 'ChangePalettePeriodically' was not declared in this scope

     ChangePalettePeriodically();

                               ^

ColorPalette:55: error: 'FillLEDsFromPaletteColors' was not declared in this scope

     FillLEDsFromPaletteColors( startIndex);

                                          ^

D:\Arduino\libraries\FastLED\examples\ColorPalette\ColorPalette.ino: In function 'void ChangePalettePeriodically()':

ColorPalette:90: error: 'SetupPurpleAndGreenPalette' was not declared in this scope

         if( secondHand == 20)  { SetupPurpleAndGreenPalette();             currentBlending = LINEARBLEND; }

                                                             ^

ColorPalette:91: error: 'SetupTotallyRandomPalette' was not declared in this scope

         if( secondHand == 25)  { SetupTotallyRandomPalette();              currentBlending = LINEARBLEND; }

                                                            ^

ColorPalette:92: error: 'SetupBlackAndWhiteStripedPalette' was not declared in this scope

         if( secondHand == 30)  { SetupBlackAndWhiteStripedPalette();       currentBlending = NOBLEND; }

                                                                   ^

ColorPalette:93: error: 'SetupBlackAndWhiteStripedPalette' was not declared in this scope

         if( secondHand == 35)  { SetupBlackAndWhiteStripedPalette();       currentBlending = LINEARBLEND; }

                                                                   ^

exit status 1
'ChangePalettePeriodically' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


I know that, and I was implying that when things go strange, and they will, you will need to start learning how to troubleshoot them on your own as well as asking.

Even if using others scripts that work fine for themā€¦ you may not have all the same supporting libraries, setup or even all the required files from ā€œtheirā€ sketch.

It sounds like you may be missing the settings.h file. When you downloaded @Jaminā€™s file, did you extract all three seperate files into the appropriately named directory in your Arduino folders?

This is how that sketchā€™s folder ESP8266-WS28xx-Blynk and itā€™s contents should look (with your own preceding folder structure of course ;))