I'm trying to use 2 potentiometers to change the color and brightness of a set of Jewels, but the LEDs aren't changing to the same color like they would on the Neopixel strip I used. This code is from a youtube video I found so any suggestions would help greatly
#include <Adafruit_NeoPixel.h>
#define LED_COUNT 60
#define LED_PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800) ;
#define p1 analogRead(1)
#define p2 analogRead(0)
int pot1;
int pot2;
void setup() {
strip.begin();
strip.show();
Serial.begin(115200);
}
void loop() {
uin32_t i;
pot1=p1;
pot2=p2;
for(int a=0;a<LED_COUNT;a++){
setPixel(a,pot1,pot2/4);
}
strip.show();
}
void setPixel(int pixelz, int colorz, long unsigned fadez) {
colorz%=1024;
if(fadez>255){
fadez=511-fadez;
}
fadez*=fadez;
fadez/=255;
strip.setPixelColor(pixelz,strip.ColorHSV(colorz*64,255,fadez));
}
Are you saying that when you attach a Neopixel strip, this code works to your satisfaction, and when you attach instead the Jewel type Neopixels it does not?
Is this parameter correct?
NEO_GRB + NEO_KHZ800
There is an RGBW variant Jewel, which do you think you have?
a7
Correct, the code works fine on my neopixel strip.
Is this parameter correct?
It was for the neopixel strip but not sure if it is for the jewel
The Jewel is the Natural White variant NeoPixel Jewel - 7 x 5050 RGBW LED w/ Integrated Drivers [Natural White - ~4500K] : ID 2859 : Adafruit Industries, Unique & fun DIY electronics and kits
I am sure it is wrong. Use
NEO_BGRW
Or one of the 23 other permutations of B, G, R and W.
Easiest: write a sketch to turn LED 1 red, 2 green, 3 blue and 4 white using BRGW or whatever.
It will probably be wrong, but you will see the correct order form the colours that do show up.
Or google for longer than that might take for the correct order.
I always put that, plus making the last pixel white, in my setup () function as a test that I have it right and the number of pixels also.
Do not fix the colours by messing with your code, that's the hole point of the constructor, to make everything else work no matter what.
HTH
a7
alto777:
NEO_BGRW
Thanks! That did the trick, code works perfectly now
1 Like
Haha, right first time? Or did you have to monkey with it?
I'm not the luckiest person, so if the first thing I wrote worked, Imma hafta go out and get some lottery tickets.
a7
Worked first try! Nothing else needed to be changed!
1 Like
system
Closed
January 4, 2025, 3:00am
8
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.