Need Help

Hello folks!

I'm working on a simple project. But i could't solve something.

#include <Adafruit_NeoPixel.h>
#define PIN 0
#define NUM_PIXELS  16
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  strip.begin();
  clearStrip();
}
void loop() {
  knightRider(1000, 20, 32, 0xF00000); // Cycles, Speed, Width, RGB Color
  clearStrip();
}
void knightRider(uint16_t cycles, uint16_t speed, uint8_t width, uint32_t color) {
  uint32_t old_val[NUM_PIXELS]; 
  for(int i = 0; i < cycles; i++){
    for (int count = 1; count<NUM_PIXELS; count++) {
      strip.setPixelColor(count, color);
      old_val[count] = color;
      for(int x = count; x>0; x--) {
        old_val[x-1] = dimColor(old_val[x-1], width);
        strip.setPixelColor(x-1, old_val[x-1]); 
      }
      strip.show();
      delay(speed);
    }
    for (int count = NUM_PIXELS-1; count>=0; count--) {
      strip.setPixelColor(count, color);
      old_val[count] = color;
      for(int x = count; x<=NUM_PIXELS ;x++) {
        old_val[x-1] = dimColor(old_val[x-1], width);
        strip.setPixelColor(x+1, old_val[x+1]);
      }
      strip.show();
      delay(speed);
    }
  }
}
void clearStrip() {
  for( int i = 0; i<NUM_PIXELS; i++){
    strip.setPixelColor(i, 0x000000); strip.show();
  }
}
uint32_t dimColor(uint32_t color, uint8_t width) {
   return (((color&0xFF0000)/width)&0xFF0000) + (((color&0x00FF00)/width)&0x00FF00) + 
     (((color&0x0000FF)/width)&0x0000FF);
}

I want to change the speed value(that is 20 -> "knightRider(1000, 20, 32, 0xF00000);") with potentiometer.
Can anyone help me with this?

Do you know how to read a value from a potentiometer using the analogRead() function ?

Sorry i don't know that. I'm a beginner:(

meuzun:
Sorry i don't know that. I'm a beginner:(

Take a look at the AnalogInput example in the IDE

Wire the pot with one end its the track to GND, the other end to 5V and the wiper to an analogue in pin then use analogRead() to get the value

UKHeliBob:
Take a look at the AnalogInput example in the IDE

Wire the pot with one end its the track to GND, the other end to 5V and the wiper to an analogue in pin then use analogRead() to get the value

I think You say add this code but i don't know where:(

int analogPin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3
                    // outside leads to ground and +5V
int val = 0;  // variable to store the value read

void setup() {
  Serial.begin(9600);           //  setup serial
}

void loop() {
  val = analogRead(analogPin);  // read the input pin
  Serial.println(val);          // debug value
}

Read the input in loop() (or a function called from loop()), convert the value read from the 0 to 1023 range to the required range using the map() function and put the result in a variable, then use the variable when calling the function instead of the value 20