Slider for Neopixel ring

This should be simple but for the life of me I can’t work out what is missing.
I have an arduino nano wired up to an adafruit 24 led neopixel ring and a HC-06 bluetooth receiver.

The code blocks for the ring and BlynkBlink to the inbuilt led work separately, i.e., before adding in the Blynk Write block. Even after this, I can control the inbuilt led with a digital button in the app, but get nothing from the ring.

I have set up a slider to just change the red value for the ring, leaving the other two at 0.

The HC-06 pairs with the Samsung phone, and communicates with the inbuilt led on the nano through a digital button on the app.
• Blynk Library version 1.8.12

As I said, this should be simple but can’t see what is missing either from the write block or elsewhere.

• Add your sketch code. :point_up:Code should be formatted as example below.

Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.

#include <Adafruit_NeoPixel.h>
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(0, 1); // RX, TX

#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "7d3f3e7dd5094d0baf71571771434b97";

// data pin
#define PIN 6
// led count
#define CNT 24
int r;
//# define g 0
//#define b 255

int position = 6;

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

    int r = param.asInt();
    Serial.print("V0 Slider value is: ");
void setup() {
    Blynk.begin(Serial, auth);


void loop() {
  // saturation - max
  // value - 0-255

    //    strip.setPixelColor((position of brightest pixel (0-23)) % CNT, red,green,blue));;
  strip.setPixelColor((position), r,0,0);;
  position %= CNT;

The int in front of the r = param.asInt() is telling the code to keep this version of the r integer variable local to the BLYNK_WRITE(V0) function.
If you want the value of r that is being modified by the slider on V0 to be visible to the rest of your code (which you do) then remove the int from this line of code.

If you want to understand more about this then google “variable scope in C++”.


Thanks Pete,

Works a treat.

And thanks for the direct to variable scope as well.

Maybe post the complete working code for the next one to use.