Here is the entire code. I defined the colors in the setup but they still show as undeclared in the other loops.
#include <Adafruit_LiquidCrystal.h>
#include <Adafruit_NeoPixel.h>
#define PIN 13
#define leds 24
Adafruit_NeoPixel strip = Adafruit_NeoPixel(leds, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_LiquidCrystal lcd_0(0);
int pb_pin = 3;
int state = 1;
bool pb;
bool pressed = false;
int pot_pin = A1;
int pot;
void setup()
{
pinMode(pb_pin, INPUT_PULLUP);
strip.begin();
Serial.begin(9600);
lcd_0.begin(20,4);
strip.clear();
uint32_t red = strip.Color(255, 0, 0); //Define the color red
uint32_t green = strip.Color(0, 255, 0); //Define the color green
uint32_t blue = strip.Color(0, 0, 255); //Define the color blue
uint32_t white = strip.Color(255, 255, 255); //Define the color white
}
void loop()
{
pb = digitalRead(pb_pin);
pot = analogRead(pot_pin);
pot = map(pot, 0, 1023, 255, 0);
if(pb == pressed){
state = state + 1;
Serial.println(state);
while(digitalRead(pb_pin) == pressed){delay(100);}
}
switch (state){
case 1:
FX1();
Serial.print("pot: ");
Serial.println(pot);
strip.setBrightness(pot);
break;
case 2:
FX2();
strip.setBrightness(pot);
break;
case 3:
FX3();
strip.setBrightness(pot);
break;
default:
strip.clear();
strip.show();
state = 0;
break;
}
}
void FX1(){
strip.clear();
strip.fill(red, 0, leds/3);
strip.fill(white, leds/3, leds/3);
strip.fill(blue, (leds/3)*2, leds/3);
strip.show();
}
void FX2(){
strip.clear();
strip.fill(green, 0, leds/4);
strip.fill(white, leds/4, leds/4);
strip.fill(green, (leds/4)*2, leds/4);
strip.fill(white, (leds/4)*3, leds/4);
strip.show();
}
void FX3(){
strip.clear();
strip.rainbow(0,1,255,255,true);
strip.show();
}