DIY under glow kit RGB strip trouble

I've been trying to make an underglow kit for my motorcycle. I'm using an Arduino nano and some WS2811 RGB strips the code compiles fine and everything goes through but. The lights don't respond they just stay white. I'm trying to control the RGB with three potentiometers for red blue and green. Use code tags to format code for the forum``Use code tags to format code for the forum

//Author: Ruben Filipe
//part of this code was made by adafruit, i just adapted it for this project. 

#include <Adafruit_NeoPixel.h> //neopixel library. Download if you don't have.

#define PIN 3 //input pin Neopixel is attached to

#define NUMPIXELS 8 //number of neopixels in strip, change if using another quantity;

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

int delayval = 100; //time delay in milliseconds, change if you want.

int redColor; //initialize variables
int greenColor;
int blueColor;

void setup() {
  Serial.begin(9600); //initialize serial
  pixels.begin(); //Initialize the NeoPixel library.
}

void loop() {
  double redColor = analogRead(0)/4.02; //Take the analog value of the potentiometer (0-1023)
  double greenColor = analogRead(1)/4.02; //and divide it by 4 so that this value is between 0-255.
  double blueColor = analogRead(2)/4.02; //the division for 4 prevents the value from exceeding 255 and causes an error.
  
  //prints the serial values of each potentiometer (Red, green, Blue). This is optional.
  Serial.print("r: "); 
  Serial.println(redColor);
 
  
  Serial.print("g: ");
  Serial.println(greenColor);
  
  
  Serial.print("b: ");
  Serial.println(blueColor);
  
  Serial.println("");
  
  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(redColor, greenColor, blueColor));

    //this sends the updated pixel color to the hardware.
    pixels.show();
    
    //delay for a period of time (in milliseconds).
    delay(delayval);
  }
}

Welcome to the forum

What do you see printed in the Serial monitor ?

That is not the Serial monitor

Click on this icon
image
top/right of the screen


It just keeps going on like this indefinitely



I'm also using these LEDs in this off brand Arduino nano

What baud rate have you got the Serial monitor set to ?

9600 I can't change it for some reason

Are these 0-2 the analog pins ( or A0-A2 )?

Yes I got the code from a pre-made sketch on tinkercad

9600 is the right baud rate for the Serial monitor to match the baud rate in the sketch

The analogRead() function is "clever" enough to interpret 0 as A0 etc but I always think that using the A* pin names is a good idea as it reinforces the difference between the normal GPIO pins and the analogue enabled pins

It is fairly common for new users to use say pin 0 when they should use pin A0

They're for analog pins A0,A1,A2 I'm trying to use three separate potentiometers to control each RGB color value

Ok, understood but seems like it is reading 255,255,255 ( so the white light )
If you are unable to make the platformio serial monitor to work ( close it ) and use a 'generic terminal' ( teraterm... ) to see the debug

The posted code #1 seems to function correctly in the wokwi simulator.

a7

That's one of the problems I was running into it works fine when I tested and tinkercad or wokwi I just don't know why it's not working in this situation :disappointed:

I'm not sure if the WS2811 LEDs I'm using are considered neopixels cuz I keep seeing people using the WS2812s

It's probably just me but the code and everything else seems so simple in terms of connections that should just work I'm not really sure where the hiccup could be

The LED strip that you posted a picture of runs at 12V whilst the Nano runs at 5V. How are the LEDs powered and have the LED strip and Nano got a common GND connection ?

Seeing a schematic, even hand drawn and photographed, would help




They are sharing a common ground. But I'm running off the power from a 12 volt power supply so the LED strip is getting power independent from the Arduino.
The potentiometers are also hooked up to 5 volt and ground on the Arduino

  • is the batt- ( or power supply - ) also connected to gnd?
  • also check you are connecting to Din side an not to Do side