WS2812B & 10k POT CONTROL

Hey guys been trying to grind this out from fresh code “picking apart code I see” tbh.

Problem :

  1. Cannot get the pot to function for brightness
  2. The pot only responds (255) when wiper or shaft is all the way left then when it hits dead center or 12 o’clock it goes to (0), rendering the other side unusable. is my map function wrong. analog is 0 - 1023, digital 0-255.
  3. Sketch runs but sporadically will stop the chase effect.
  4. I run serial monitor and I can see my “resetting” and “x” , as well as my values for my pot.

Any help would be awesome!

#include <FastLED.h>

#define NUM_LEDS 20
#define DATA_PIN 5
// #define DATA_PIN 6
CRGB leds[NUM_LEDS];

int analogPin = A0;
int ana_val = 0;

void setup() { 
  pinMode(DATA_PIN, OUTPUT);
  pinMode(analogPin, OUTPUT);
  
  LEDS.addLeds<WS2812B,DATA_PIN,RGB>(leds,NUM_LEDS);
  LEDS.setBrightness(100);
  Serial.begin(9600);
  Serial.println("resetting");

}

void fadeall() { 
  for(int i = 0; i < NUM_LEDS; i++) { 
  leds[i].nscale8(250); 
 
} 
}

void loop() { 
  
    {

  analogPin = analogRead(A0);
  ana_val = map(analogPin, 0, 1023, 0, 255);
  analogWrite(DATA_PIN, ana_val);
  Serial.println(ana_val);
  
  }

  static uint8_t hue = 0;
  Serial.print("x");
  // First slide the led in one direction
  for(int i = 0; i < NUM_LEDS; i++) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show(); 
    // now that we've shown the leds, reset the i'th led to black
    // leds[i] = CRGB::Black;
    fadeall();
    // Wait a little bit before we loop around and do it again
    delay(50);
  
  }
  Serial.print("x");

  // Now go in the other direction.  
  for(int i = (NUM_LEDS)-1; i >= 0; i--) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show();
    // now that we've shown the leds, reset the i'th led to black
    // leds[i] = CRGB::Black;
    fadeall();
    // Wait a little bit before we loop around and do it again
    delay(20);
   
  }

}
pinMode(analogPin, OUTPUT);

This is the pin the pot is connected to?

analogWrite(DATA_PIN, ana_val);

This is the pin connected to the ws2812 strip? The strip does not take a pwm signal.

Any help would be awesome!

You have jumped in the deep end of the pool and you haven't taken any swimming lessons yet. The water looks so inviting. The other guys make swimming look so easy. You can do that too, but you've got to start in the shallow end and learn your strokes, breathing, not drowning etc. Start with basic Arduino tutorials, understand inputs, outputs, basic coding. Might seem boring but you have to do it.

i think you better set another momentary pushbutton instead of a trimmer
each time you press the button the brightnes changes (multiple pre set dimmer, for example- normal is 50, one press 100, second press 150...)

but you have to define the presets

Thank you for your responses,
I had impressions I would receive a paragraph like that from @PaulRB, thank you for the pool analogy.
I've dipped around on the tuts, ill go back around its not boring to code, you don't need to say that, I spent a good couple hours on that not working code and I feel good, I thought I had my variables in place, but thanks for the message!!!!

@bernte_one, I must do some more research! thank you for the response