ws2812 LED programming problem

I want to place LED lighting above my galley or to just simply use it as a nightlight, accent lighting, whatever. I have the color and brightness figured out using potentiometers but I cant figure out how to sequentially light them up with a third Pot and insert that into my loop. Working code is below.

ws2812 addressable LED waterproof lightstrip.
3 10k SPST potentiometers for color, brightness and number of LED’s.
The SPST is to turn the circuit on, all in one knob, perfect. The brightness pot will be the on/off but you have to buy these pots in packages… The color pot will be for white as there is no white in rainbow spectrum.

So heres what I have planned;

60 LED’s spanning 7’.
Arduino reads on analog pins a voltage ranging from 0-1023. so resistance/6=170.5
so r<=170 = 1 led (c), =>340 = 2 led’s (c) and etc.

X=black
C=pot color

Aft Fwd
Stove Sink Refrigerator
1 60
data flow=>
<=170 xxxxxcxxxxxcxxxxxcxxxxxcxxxxxcxxxxxcxxxxxcxxxxxcxxxxxcxxxxxc
=>340 xxxxccxxxxccxxxxccxxxxccxxxxccxxxxxcxxxxccxxxxccxxxxccxxxxcc
=>510 xxxcccxxxcccxxxcccxxxcccxxxcccxxxcccxxxcccxxxcccxxxcccxxxccc
=>680 xxccccxxccccxxccccxxccccxxccccxxccccxxccccxxccccxxccccxxcccc
=>850 xcccccxcccccxcccccxcccccxcccccxcccccxcccccxcccccxcccccxccccc
=>980 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

What am I doing wrong?
I still have to add the POT line, but the code as it is doesn’t compile.

//

#include <Adafruit_NeoPixel.h>
// can use #include <FastLed.h>

const int STRIP_LENGTH = 60;

const int LED_STRIP_PIN = 10;

const int BRIGHTNESS_POT = A6;
const int BRIGHTNESS_SWITCH = 8;

const int COLOR_POT = A3;
const int BRIGHTNESS_SWITCH = 6;

float brightness = 0.0;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(STRIP_LENGTH, LED_STRIP_PIN,
NEO_GRB + NEO_KHZ800);

void setup() {

pinMode(COLOR_POT, INPUT);
pinMode(COLOR_SWITCH, INPUT_PULLUP);
pinMode(BRIGHTNESS_POT, INPUT);
pinMode(BRIGHTNESS_SWITCH, INPUT_PULLUP);
strip.begin();
strip.show();
}

void loop() {
if (digitalRead(BRIGHTNESS_SWITCH) == HIGH) {
// Get the percentage of the full brightness.
brightness = 1.0 - (analogRead(BRIGHTNESS_POT) / 1023.0);
Serial.println(brightness);
if (digitalRead(COLOR_SWITCH) == HIGH) {
// Scale down the color range.
int color = (analogRead(COLOR_POT) / 1023.0) * 245.0;
calculateAndChangeColor(color);
} else {
// Color is disabled. Change strip to white.
changeColor(255, 255, 255);
}
} else {
changeColor(0,0,0);
}

delay(50);

}

void changeColor(int red, int green, int blue) {
int i;
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, redbrightness, greenbrightness, blue*brightness);
}
strip.show();
}

// This is based on the Adafruit NeoPixel strandtest example.
void calculateAndChangeColor(int potValue) {
int red = 0;
int green = 0;
int blue = 0;
if(potValue < 85) {
red = potValue * 3;
green = 255 - potValue * 3;
} else if(potValue < 170) {
potValue -= 85;
red = 255 - potValue * 3;
blue = potValue * 3;
} else {
potValue -= 170;
green = potValue * 3;
blue = 255 - potValue * 3;
}
changeColor(red, green, blue);

}

If you have code that doesnt compile, post the errors uou get - most of us answer these when were not at our computers with the IDE (if we were, wed be working on our own projects!), and nobody wants to bother comppiling others code while helping other people for free.

Also, use code tags ehen posting code or error output.

line 36, calculateAndChangeColor(color); was not declared in this scope.. i'm missing something stupid.

copy paste hell…

the above code works. This is what doesn’t compile,

#include <Adafruit_NeoPixel.h>

const int STRIP_LENGTH = 1;

const int LED_STRIP_PIN = 10;

const int BRIGHTNESS_POT = A6;
const int BRIGHTNESS_SWITCH = 8;

const int COLOR_POT = A3;
const int COLOR_SWITCH = 6;

float brightness = 0.0;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(STRIP_LENGTH, LED_STRIP_PIN,
NEO_GRB + NEO_KHZ800);

void setup() {

pinMode(COLOR_POT, INPUT);
pinMode(COLOR_SWITCH, INPUT_PULLUP);
pinMode(BRIGHTNESS_POT, INPUT);
pinMode(BRIGHTNESS_SWITCH, INPUT_PULLUP);
strip.begin();
strip.show();
}

void loop() {
if (digitalRead(BRIGHTNESS_SWITCH) == HIGH) {
// Get the percentage of the full brightness.
brightness = 1.0 - (analogRead(BRIGHTNESS_POT) / 1023.0);
Serial.println(brightness);
if (digitalRead(COLOR_SWITCH) == HIGH) {
// Scale down the color range.
int color = (analogRead(COLOR_POT) / 1023.0) * 245.0;
calculateAndChangeColor(color);
} else {
// Color is disabled. Change strip to white.
changeColor(255, 255, 255);
}
} else {
changeColor(0,0,0);
}

delay(50);

void changeColor(int red, int green, int blue) {
int i;
for (i = 0, i < 60, i++) {
strip.setPixelColor(i, 0, 0, 0);
if ((i % 6) == 5) { // finds 5, 11, 17 etc
if (brightness > 0) strip.setPixelColor(i, redbrightness, greenbrightness, bluebrightness); // pixel 5, 11, 17…
if (brightness > 170) strip.setPixelColor(i-1,red
brightness, greenbrightness, bluebrightness); // pixel 4, 10, 16…
if (brightness > 340) strip.setPixelColor(i-2,redbrightness, greenbrightness, bluebrightness); // pixel 3, 9, 15…
if (brightness > 510) strip.setPixelColor(i-3,red
brightness, greenbrightness, bluebrightness); // pixel 2, 8, 14…
if (brightness > 680) strip.setPixelColor(i-4,redbrightness, greenbrightness, bluebrightness); // pixel 1, 7, 13…
if (brightness > 850) strip.setPixelColor(i-5,red
brightness, greenbrightness, bluebrightness); // pixel 0, 6, 12…
}
}
}

// This is based on the Adafruit NeoPixel strandtest example.
void calculateAndChangeColor(int potValue) {
int red = 0;
int green = 0;
int blue = 0;
if(potValue < 85) {
red = potValue * 3;
green = 255 - potValue * 3;
} else if(potValue < 170) {
potValue -= 85;
red = 255 - potValue * 3;
blue = potValue * 3;
} else {
potValue -= 170;
green = potValue * 3;
blue = 255 - potValue * 3;
}
changeColor(red, green, blue);

}

Bracket issue… sort of resolved… I’m thinking i’ve been looking at this to long to notice my mistakes. So now I have another bracket issue and I think I have to change the part where it looks for brightness at line 80…

So line 77, expected ‘;’ before ‘)’

current code,

#include <Adafruit_NeoPixel.h>

const int STRIP_LENGTH = 1;
const int LED_STRIP_PIN = 10;
const int BRIGHTNESS_POT = A6;
const int BRIGHTNESS_SWITCH = 8;
const int COLOR_POT = A3;
const int COLOR_SWITCH = 6;

float brightness = 0.0;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(STRIP_LENGTH, LED_STRIP_PIN,NEO_GRB + NEO_KHZ800);

void setup() {
pinMode(COLOR_POT, INPUT);
pinMode(COLOR_SWITCH, INPUT_PULLUP);
pinMode(BRIGHTNESS_POT, INPUT);
pinMode(BRIGHTNESS_SWITCH, INPUT_PULLUP);
strip.begin();
strip.show();
}

void loop() {

if (digitalRead(BRIGHTNESS_SWITCH) == HIGH) {
// Get the percentage of the full brightness.
brightness = 1.0 - (analogRead(BRIGHTNESS_POT) / 1023.0);
Serial.println(brightness);
if (digitalRead(COLOR_SWITCH) == HIGH) {
// Scale down the color range.
int color = (analogRead(COLOR_POT) / 1023.0) * 245.0;
calculateAndChangeColor(color);
} else {
// Color is disabled. Change strip to white.
changeColor(255, 255, 255);
}
} else {
changeColor(0,0,0);
}

delay(50);
}

// void changeColor(int red, int green, int blue) {
// int i;
// for(i=0; i< strip.numPixels(); i++) {
// strip.setPixelColor(i, redbrightness, greenbrightness, blue*brightness);
// }
// strip.show();
// }

// This is based on the Adafruit NeoPixel strandtest example.
void calculateAndChangeColor(int potValue) {
int red = 0;
int green = 0;
int blue = 0;
if(potValue < 85) {
red = potValue * 3;
green = 255 - potValue * 3;
} else if(potValue < 170) {
potValue -= 85;
red = 255 - potValue * 3;
blue = potValue * 3;
} else {
potValue -= 170;
green = potValue * 3;
blue = 255 - potValue * 3;
}
changeColor(red, green, blue);
}

void changeColor(int red, int green, int blue) {
int i;
for (i = 0, i < 60, i++) {
strip.setPixelColor(i, 0, 0, 0);
if ((i % 6) == 5) { // finds 5, 11, 17 etc
if (brightness > 0) strip.setPixelColor(i, redbrightness, greenbrightness, bluebrightness); // pixel 5, 11, 17…
if (brightness > 170) strip.setPixelColor(i-1,red
brightness, greenbrightness, bluebrightness); // pixel 4, 10, 16…
if (brightness > 340) strip.setPixelColor(i-2,redbrightness, greenbrightness, bluebrightness); // pixel 3, 9, 15…
if (brightness > 510) strip.setPixelColor(i-3,red
brightness, greenbrightness, bluebrightness); // pixel 2, 8, 14…
if (brightness > 680) strip.setPixelColor(i-4,redbrightness, greenbrightness, bluebrightness); // pixel 1, 7, 13…
if (brightness > 850) strip.setPixelColor(i-5,red
brightness, greenbrightness, bluebrightness); // pixel 0, 6, 12…
}
}
}