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);
}
}
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
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
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
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