Neopixel via blynk app

Hi,

I try to control a Neopixel-Ring (24 LEDs) with blynk app. I managed to control the Neopixel-Ring via php but I have now idea how to do this via blynk. Any suggestions?

Cheers
cbmainz

We will definitely need additional information to help. What have you tried? What code do you have so far? What errors are you running into?

1 Like

It took me a while, but now I managed to control the Neopixel-Ring with blynk app and the zeRGBa-Widget:

BLYNK_WRITE(V4)
    {
      int r = param[0].asInt(); // get a RED channel value
      int g = param[1].asInt(); // get a GREEN channel value
      int b = param[2].asInt(); // get a BLUE channel value
      for (int i = 0; i < strip.numPixels(); i++)
      {
        strip.setPixelColor(i, r, g, b);
      }
      strip.show();
    }

But I also what to have a button to start the rainbow-loop. I tried this so far:

BLYNK_WRITE(V3)
{
  int pindata = param.asInt();

  for(pindata = 0; pindata < 1;) {
  for(int j=0; j<256; j++) {
    for(int i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(50);
  }
  }
}

Full code: https://crowdapp.de/NoTGbF

@cbmainz, what is the issue? Perhaps instead of doing the rainbow loop in BLYNK_WRITE(V3), set a flag for loop() to check and do the rainbow code there.

1 Like

In void loop() this is running:

{
  Blynk.run();
}

What’s preventing you from adding code to that ;)?

Nothing, but I what to have Rainbow not always on. I like to choose between rainbow or a single color and maybe late a different program. And I need to turn it off some way.

@peekay123’s suggestion of adding a flag that blynk toggles, and you check for in your loop() is what you want to do. Then in that loop() you can run your code if the flag is true. Don’t forget to disable other flags when setting a new one.

1 Like

Okay, thanx @BDub, I’m quite new to this and didn’t work with flags before. I have to read about this and try it out.

1 Like

A ‘flag’ is nothing special, it’s just a Boolean variable to set to true or false. “If (blinkyThing == true){ do the blinkyThing thing}”.
External interaction can then toggle their respective ‘flags’.

1 Like