NEOPIXEL Arduino Nano via HC-05. need help with the zeRGBa mode

Hi guys! i’m new to arduino and i’m trying to make my neopixel ring work with blynk. I used the example code fot my BT device, it connects and the app recognizes the bluetooth but the neopixels don’t seem to respond.

I want to use the zeRGBa widget.

i used this code :slight_smile:

#define BLYNK_PRINT Serial


#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
    #include <BlynkSimpleSerialBLE.h>
#include <Adafruit_NeoPixel.h>


char auth[] = "bcbc198b969948b4b39d1a01c97a00f2";

SoftwareSerial SerialBLE(10, 11); // RX, TX

#define PIN A5

Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if (WheelPos < 85) {
    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if (WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
    WheelPos -= 170;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

BLYNK_WRITE(V1)
{
  int shift = param.asInt();
  for (int i = 0; i < strip.numPixels(); i++)
  {
  strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + shift) & 255));
  }
  strip.show();
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);

  Serial.println("Waiting for connections...");

  strip.begin();
  strip.show();
}

void loop()
{
  Blynk.run();
}

zeRGBa sends three values. Did you set it up in your Blynk project to SPLIT or MERGE mode? and what pins have you selected for the widget?

Hi shurik179, i’m using it in merge mode, with the V1 virtual pin. I guess the example code sets it up like that? or do i have to declare it in some way?

In merge mode, values should be read as follows (see http://docs.blynk.cc/#widgets-controllers-zergba )

BLYNK_WRITE(V1) // zeRGBa assigned to V1 
{
    // get a RED channel value
    int r = param[0].asInt();
    // get a GREEN channel value
    int g = param[1].asInt();
    // get a BLUE channel value
    int b = param[2].asInt();
}

Try this:

#include <Adafruit_NeoPixel.h>
#define D0 16 
#define PIN D0
#define NUMPIXELS 1 

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, 13, NEO_GRB + NEO_KHZ800);

Then

BLYNK_WRITE(V1)
{
int R = param[0].asInt();
int G = param[1].asInt();
int B = param[2].asInt();

for(int i=0;i<NUMPIXELS;i++){
    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(R,G,B)); // Moderately bright green color.
    pixels.show(); // This sends the updated pixel color to the hardware.
}
}

void loop()
{
  Blynk.run();
}

HI Guys! thank you so much for your help! It’s working!:heart_eyes:

1 Like