Control LED Strip with Data Pin with a Potentiometer

Hello, folks! I am quite new in arduino. In my new project, I' m trying to control a rgb led strip with a data pin with a potentiometer that changes the color of the strip. unfortunately i can't code arduino very well and now i'm asking for your help. I can't find anything in the web and now im asking you guys.

(I'm not the best at writing in english, i speak german normally :stuck_out_tongue: )

Thanks in advance

regards
DarioCas

OK, the first step is to detail what parts you have on hand - you need to specify which Arduino you have (whether it is a genuine or a clone) and the Web references to each other part you have including your 5 V power supply.

If you have already attempted to connect things together, then a diagram and preferably a photo of what you have assembled. And read the instructions for how to post these.

Paul__B:
OK, the first step is to detail what parts you have on hand - you need to specify which Arduino you have (whether it is a genuine or a clone) and the Web references to each other part you have including your 5 V power supply.

If you have already attempted to connect things together, then a diagram and preferably a photo of what you have assembled. And read the instructions for how to post these.

Hi! Thanks for your reply!

I've got a Arduino NANO and a LED Strip with a Data Pin.

I haven't connected anything together yet. This is something new for me and asking the help of the Community.

Regards
DarioCas

LED strips come in many different types needing different code. What EXACT LED strip do you have? What voltage ? How many LEDs? Does it have a type code like WS2812B or similar? Can each LED be controlled independently?

A link to a datasheet or at least to where you bought it would save you having to answer so many questions.

A Nano should be fine. The potentiometer should be 10K linear.

Steve

slipstick:
LED strips come in many different types needing different code. What EXACT LED strip do you have? What voltage ? How many LEDs? Does it have a type code like WS2812B or similar? Can each LED be controlled independently?

A link to a datasheet or at least to where you bought it would save you having to answer so many questions.

A Nano should be fine. The potentiometer should be 10K linear.

Steve

Hi Steve!

I’ve got an LED strip with a GND pin, a 5V+ pin and a Data Pin.

but i Solved it myseolf with a lot of research and my friend helped me a bit out.

for everyone who’s interested in, here’s the code:

#include <Adafruit_NeoPixel.h>
#define PIN 4
#define NUM_LIGHTS  4

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

int currentColorValueRed;
int currentColorValueGreen;
int currentColorValueBlue;
int colorData;
int brightnessValue;

int ColorPotPin = A2;
int brightnessPotPin = A3;

void setup() {
  pinMode(ColorPotPin, INPUT);
  pinMode(brightnessPotPin, INPUT);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  
  	int potPinValue = map(analogRead(ColorPotPin), 0, 1024, 0, 255);
  
  	int brightnessPot = map(analogRead(brightnessPotPin), 0, 1024, 1, 255);
  
  	float brightnessValue = brightnessPot / 255.0;
  	
  	if (potPinValue <= 42.5) {
		currentColorValueRed = 255;
		currentColorValueGreen = potPinValue * 6;
		currentColorValueBlue = 0;
   }
   
   if ((potPinValue > 42.5) && (potPinValue <= 85)) {
		currentColorValueRed = 255 - (potPinValue - 43) * 6;
		currentColorValueGreen = 255;
		currentColorValueBlue = 0;
   }
   
   if ((potPinValue > 85) && (potPinValue <= 127.5)) {
		currentColorValueRed = 0;
		currentColorValueGreen = 255;
		currentColorValueBlue = (potPinValue - 85) * 6;   }
   
	if ((potPinValue > 127.5) && (potPinValue <= 170)) {
		currentColorValueRed = 0;
		currentColorValueGreen = 255 - (potPinValue - 127.5) * 6;
		currentColorValueBlue = 255;
	}
   
	if ((potPinValue > 170) && (potPinValue <= 212.5)) {
		currentColorValueRed = (potPinValue - 170) * 6;
		currentColorValueGreen = 0;
		currentColorValueBlue = 255;
	}
	
	if ((potPinValue > 212.5) && (potPinValue <= 255)) {
		currentColorValueRed = 255;
		currentColorValueGreen = 0;
		currentColorValueBlue = 255 - (potPinValue - 212.5) * 6;
	}
  	
  	uint32_t high = strip.Color(currentColorValueRed * brightnessValue, currentColorValueGreen * brightnessValue, currentColorValueBlue * brightnessValue);
  	
  	for( int i = 0; i<NUM_LIGHTS; i++){
        strip.setPixelColor(i, high);
        strip.show();
    }
     delay(10);
}

on pin A2 the potentiometer for the color is connected.
on pin A3 the potentiometer for the brightness is connected.
on pin 4 the Data Pin of the led strip is connected.

Thanks for everyone that helped me out :wink: