I'm trying to code a program but the lists/arrays are being difficult

I want a code that can be used to change the setting of a setting, but trying to simplify things a bit, I had some difficulties with making an array, and then changing the array to something else like { 30, 5, 1 } to { 1, 5, 30 }

Here's the code I'm using;

#include <Adafruit_NeoPixel.h>

#define RAINBOWSPEED 1      // the larger the number, the slower the rate of change (1 default)
#define LED_PIN 13          // Pin where the LED strip is connected
#define NUM_LEDS 36         // Number of LEDs in the strip
#define LIGHTCHANGESPEED 1  // the larger the number, the slower the rate of change (1 default)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

bool reset_on_exit = false;
const int buttonPin = 11;                // Pin where the button is connected
const int Relay_enable_IALS_input = 12;  // Pin where the Relay is connected
bool ledState = false;                   // holds the state of the LED
int speaker_pin1 = 10;
int speaker_pin2 = 8;
int cur_pos = 13;
int rst_pin = 9;
void setup() {
  digitalWrite(9, HIGH);
  pinMode(rst_pin, OUTPUT);
  digitalWrite(speaker_pin1, HIGH);
  Serial.begin(9600);
  strip.setPixelColor(cur_pos, 255, 0, 255);
  strip.show();
  strip.begin();  // Initialize the strip
  strip.show();
  pinMode(speaker_pin1, OUTPUT);
  pinMode(speaker_pin2, OUTPUT);                    // Initialize all pixels to 'off'
  pinMode(buttonPin, INPUT);                        // Set the button pin as an input
  pinMode(Relay_enable_IALS_input, OUTPUT);         // Set the Relay_enable_IALS_input as an output
  digitalWrite(Relay_enable_IALS_input, ledState);  // Initialize the relay state 255 * (1 / 100)
  delay(100);
  colorWipe(0, 0, 0, 0, false);
  strip.show();
}

int action = 0;
bool action_deleteCurSprite = true;
void loop() {
  if (action > 0 && action_deleteCurSprite == true) {
    strip.setPixelColor(cur_pos, 0, 0, 0);
    strip.show();
    action_deleteCurSprite = false;
  } else if (action == 0) {
    action_deleteCurSprite = true;
  }
  initiative();
  reset();
  buttonpanelRead();
  stop(0);
  actionAray();
  button_sequence();
}
// Fill the dots one after the other with a color
bool selector = true;
float potVal = analogRead(0);  // stores the input from the potentiometer
float brightness = potVal / 1000;


bool lastButtonState = LOW;  // holds the last button state
bool pause = false;
float timer = 0;
bool timerEnabled = false;
void button_sequence() {
  if (timerEnabled == true) {
    timer = timer - 0.001;
    // Serial.println(timer);
    if (timer <= 0 && timerEnabled == true) {
      action = 0;
      timerEnabled = false;
      pause = true;
      delay(300);
      // Serial.println("action completed");
      for (int oe = 0; oe < 37; oe++) {
        strip.setPixelColor(oe, 0, 0, 0);
        strip.show();
      }
      selector = true;
      cur_pos = 13;
      strip.setPixelColor(cur_pos, 255, 0, 255);
      strip.show();
    }
  }

  bool buttonState = digitalRead(buttonPin);
  if (buttonState != lastButtonState) {
    if (buttonState == HIGH) {
      ledState = !ledState;
      digitalWrite(Relay_enable_IALS_input, ledState);
    }
    delay(50);
  }
  lastButtonState = buttonState;
}

int button_left = 4;
int button_right = 5;
int button_up = 7;
int button_down = 6;
int button_ok = 3;
int button_back = 2;
void actionAray() {
  if (action == 1) {
    runAction_defaultColorpattern();
  } else if (action == 2) {
    runAction_flashlight();
  } else if (action == 3) {
    runAction_globalflashlight();
  } else if (action == 4) {
    runAction_speaker();
  } else if (action == 5) {
    runAction_5();
  } else if (action == 6) {
    runAction_6();
  } else if (action == 7) {
    runAction_lowpowerconsumption();
  } else if (action == 8) {
    runAction_8();
  } else if (action == 9) {
    runAction_SOS();
  }
}
// normal rainbow pattern

int wait = 0;
int Delay_between_colorWipe_cycle = 0;
int r = 255;
int g = 255;
int b = 255;
int cnt = 0;
int cnt2 = 1;
void runAction_defaultColorpattern() {
  if (wait == 0) {
    wait = 1;
    while (action == 1) {
      colorWipe(0, 0, 0, 0, true);
      colorWipe(255 * brightness, 0 * brightness, 0 * brightness, LIGHTCHANGESPEED * 50, true);  // Red color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(255 * brightness, 100 * brightness, 0 * brightness, LIGHTCHANGESPEED * 50, true);  // Orange color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(255 * brightness, 200 * brightness, 0 * brightness, LIGHTCHANGESPEED * 50, true);  // Yellow color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(100 * brightness, 255 * brightness, 0 * brightness, LIGHTCHANGESPEED * 50, true);  // Lime color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(0 * brightness, 255 * brightness, 0 * brightness, LIGHTCHANGESPEED * 50, true);  // Green color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(0 * brightness, 255 * brightness, 50 * brightness, LIGHTCHANGESPEED * 50, true);  // Turquoise color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(0 * brightness, 255 * brightness, 255 * brightness, LIGHTCHANGESPEED * 50, true);  // Cyan color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(0 * brightness, 100 * brightness, 255 * brightness, LIGHTCHANGESPEED * 50, true);  // Light Blue color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(0 * brightness, 0 * brightness, 255 * brightness, LIGHTCHANGESPEED * 50, true);  // Blue color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(120 * brightness, 0 * brightness, 255 * brightness, LIGHTCHANGESPEED * 50, true);  // Purple color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(255 * brightness, 0 * brightness, 200 * brightness, LIGHTCHANGESPEED * 50, true);  // Magenta color
      delay(Delay_between_colorWipe_cycle);
      colorWipe(255 * brightness, 255 * brightness, 255 * brightness, LIGHTCHANGESPEED * 50, true);  // No color shift
      delay(Delay_between_colorWipe_cycle);
      double lumn_temp = brightness;
      r = 255;
      g = 255;
      b = 255;
      cnt = 0;
      cnt2 = 1;
      striprainbowGenerator(200, 1, brightness, 0, 37);  // Rainbow effect speed
    }
    wait = 0;
  }
  colorWipe(0, 0, 0, 0, true);
  strip.setPixelColor(cur_pos, 255, 0, 255);
}
// front flashlight
float brightness_mem = brightness;
bool repeater = false;
int waitonfirstactivation1 = 100;
void runAction_flashlight() {
  bool wait = true;
  primeBrightness();
  if (repeater == false || round(brightness_mem * 20) != round(brightness * 20)) {
    if (digitalRead(button_ok) == LOW) {
      wait = true;
    } else {
      wait = false;
    }
    if (wait == true) {
      // Serial.println(brightness_mem);
      // Serial.println(brightness);
      repeater = true;
      brightness_mem = brightness;
      for (int i = 1; i < 10; i++) {
        strip.setPixelColor(i + 8, r * brightness, g * brightness, b * brightness);
        strip.show();
      }
    }
  }
  if (digitalRead(button_right) == HIGH) {
    repeater = false;
    striprainbowGenerator(100, 0, brightness, 1, 0);
  } else if (digitalRead(button_back) == HIGH) {
    if (reset_on_exit == true) {
      cnt2 = 1;
      cnt = 0;
      r = 255;
      g = 255;
      b = 255;
    }
  }
  if (repeater == true) {
    strip.setPixelColor(cur_pos, r * brightness, g * brightness, b * brightness);
    strip.show();
  }
}
// global flashlight
void runAction_globalflashlight() {
  bool wait = true;
  primeBrightness();
  if (repeater == false || round(brightness_mem * 20) != round(brightness * 20)) {
    if (digitalRead(button_ok) == LOW) {
      wait = true;
    } else {
      wait = false;
    }
    if (wait == true) {
      // Serial.println(brightness_mem);
      // Serial.println(brightness);
      repeater = true;
      brightness_mem = brightness;
      colorWipe(r * brightness, g * brightness, b * brightness, 0, true);
    }
  }
  if (digitalRead(button_right) == HIGH) {
    repeater = false;
    striprainbowGenerator(100, 0, brightness, 0, 0);
  } else if (digitalRead(button_back) == HIGH) {
    if (reset_on_exit == true) {
      cnt2 = 1;
      cnt = 0;
      r = 255;
      g = 255;
      b = 255;
    }
  }
  if (repeater == true) {
    strip.setPixelColor(cur_pos, r * brightness, g * brightness, b * brightness);
    strip.show();
  }
}

void runAction_speaker() {
  uint64_t myInts[] = { 200, 400, 800, 16, 1000, 1000 };  // audio input here delayed by 300 ms
  Serial.println();
  int deltym = 300;
  for (int ds = 0; ds < sizeof(myInts) / 8; ds++) {
    if (selector == false) {
      tone(speaker_pin1, myInts[ds], deltym);
      stop(deltym);
    }
  }
}

void runAction_5() {
  random_ColorGenerator();
  stop(0);
}
float SubDelay = 0;
int sleep_color = 1;
// sleep length is equivalent to the minnuts it takes to auto power off. 5 min is default
int sleep_length = 5;
int sleep_;
int setting = 1;

void runAction_6() {
  while (digitalRead(button_ok) == HIGH) {
    delay(1);
  }
  if (repeater == false) {
    // 3 modes/lengths that play music, and show a peaceful lighting
    if (setting == 1) {
      if (digitalRead(button_up) == HIGH && sleep_color < 3) {
        delay(300);
        sleep_color = sleep_color + 1;
      } else if (digitalRead(button_down) == HIGH && sleep_color > 1) {
        delay(300);
        sleep_color = sleep_color - 1;
      }
    } else if (setting == 0) {
      if (digitalRead(button_up) == HIGH && sleep_length < 30) {
        delay(300);
        sleep_length = sleep_length + 1;
      } else if (digitalRead(button_down) == HIGH && sleep_length > 1) {
        delay(300);
        sleep_length = sleep_length - 1;
        uint32_t cl[];                                                                       This part is giving me trouble.
        for (int px = 0; px < sleep_length; px++) {
          if (sleep_color = 1) {
            cl = 1;
          }

          strip.setPixelColor(px, cl);
        }
      }
    }
    if (digitalRead(button_ok) == LOW) {
      if (sleep_color == 1) {
        strip.setPixelColor(10, 0, 0, 0);
        strip.setPixelColor(13, 0, 0, 0);
        strip.setPixelColor(16, 255, 0, 0);
        strip.show();
      } else if (sleep_color == 2) {
        strip.setPixelColor(10, 0, 0, 0);
        strip.setPixelColor(13, 255, 255, 0);
        strip.setPixelColor(16, 255, 0, 0);
        strip.show();
      } else if (sleep_color == 3) {
        strip.setPixelColor(10, 0, 0, 255);
        strip.setPixelColor(13, 255, 255, 0);
        strip.setPixelColor(16, 255, 0, 0);
        strip.show();
      }
    }
    delay(50);
    if (digitalRead(button_left) == HIGH && setting < 1) {
      setting = setting + 1;
    } else if (digitalRead(button_right) == HIGH && setting > -1) {
      setting = setting - 1;
    }
    if (digitalRead(button_ok) == HIGH) {
      if (sleep_color == 1) {
        repeater = true;
        // sleep 2 minuts
        SubDelay = 12000;
        while (SubDelay > 0) {
          if (digitalRead(button_back) == HIGH) {
            SubDelay = 0;
            action = 0;
            stop(0);
          } else {
            for (int p = 0; p < 37; p++) {
              strip.setPixelColor(p, random(30), random(4), random(1));
              strip.show();
            }
            delay(1);
            SubDelay = SubDelay - 5;
            // Serial.println(SubDelay);
          }
        }
        exit();
      } else if (sleep_color == 2) {
        repeater = true;
        // sleep 5 minuts
        SubDelay = 30000;
        while (SubDelay > 0) {
          if (digitalRead(button_back) == HIGH) {
            SubDelay = 0;
            action = 0;
            stop(0);
          } else {
            for (int p = 0; p < 37; p++) {
              strip.setPixelColor(p, random(30), random(30), random(4));
              strip.show();
            }
            delay(1);
            SubDelay = SubDelay - 5;
            // Serial.println(SubDelay);
          }
        }
        exit();
      } else if (sleep_color == 3) {
        repeater = true;
        // sleep 10 minuts
        SubDelay = 60000;
        while (SubDelay > 0) {
          if (digitalRead(button_back) == HIGH) {
            SubDelay = 0;
            action = 0;
            stop(0);
          } else {
            for (int p = 0; p < 37; p++) {
              strip.setPixelColor(p, random(1), random(10), random(30));
              strip.show();
            }
            delay(1);
            SubDelay = SubDelay - 5;
            // Serial.println(SubDelay);
          }
        }
        exit();
      }
    }
  }
}


void runAction_lowpowerconsumption() {
  int wait3 = true;

  if (digitalRead(button_ok) == LOW) {
    wait3 = false;
  }
  if (digitalRead(button_up) == HIGH && timer < 37) {
    timer = timer + 1;
    for (int pixletimer_num = 0; pixletimer_num < timer; pixletimer_num++) {
      // Serial.println(timer);
      strip.setPixelColor(pixletimer_num, 255, 255, 255);
      strip.show();
    }
  } else if (digitalRead(button_down) == HIGH && timer >= 0) {

    // Serial.println(timer);
    strip.setPixelColor(timer, 0, 0, 0);
    strip.show();
    timer = timer - 1;
  }
  delay(150);
  if (wait3 == false && digitalRead(button_ok) == HIGH) {
    action = 0;
    if (selector == false) {
      repeater = false;
      cur_pos = 13;
      delay(300);
      colorWipe(0, 0, 0, 0, true);
      strip.setPixelColor(cur_pos, 255, 0, 255);
      strip.show();
      selector = true;
      timerEnabled = true;
    }
  }
}

void runAction_8() {
  if (repeater == false) {
    repeater = true;
    colorWipe(0, 0, 0, 0, true);  // No color shift
  }
}
// SOS
void runAction_SOS() {
  if (wait == 0) {
    wait = 9;
    while (action == 9) {
      colorWipe(255, 255, 25, 0, true);
      colorWipe(255, 255, 25, 2, true);
      colorWipe(0, 0, 0, 0, true);
      colorWipe(0, 0, 0, 3, true);
      colorWipe(255, 255, 25, 0, true);
      colorWipe(255, 255, 25, 2, true);
      colorWipe(0, 0, 0, 0, true);
      colorWipe(0, 0, 0, 3, true);
      colorWipe(255, 255, 25, 0, true);
      colorWipe(255, 255, 25, 2, true);
      colorWipe(0, 0, 0, 0, true);
      colorWipe(0, 0, 0, 5, true);
      colorWipe(255, 255, 25, 0, true);
      colorWipe(255, 255, 25, 20, true);
      colorWipe(0, 0, 0, 0, true);
      colorWipe(0, 0, 0, 1, true);
      colorWipe(255, 255, 25, 0, true);
      colorWipe(255, 255, 25, 20, true);
      colorWipe(0, 0, 0, 0, true);
      colorWipe(0, 0, 0, 1, true);
      colorWipe(255, 255, 25, 0, true);
      colorWipe(255, 255, 25, 20, true);
      colorWipe(0, 0, 0, 0, true);
      colorWipe(0, 0, 0, 5, true);
      colorWipe(255, 255, 25, 0, true);
      colorWipe(255, 255, 25, 2, true);
      colorWipe(0, 0, 0, 0, true);
      colorWipe(0, 0, 0, 3, true);
      colorWipe(255, 255, 25, 0, true);
      colorWipe(255, 255, 25, 2, true);
      colorWipe(0, 0, 0, 0, true);
      colorWipe(0, 0, 0, 3, true);
      colorWipe(255, 255, 25, 0, true);
      colorWipe(255, 255, 25, 2, true);
      colorWipe(0, 0, 0, 0, true);
      colorWipe(0, 0, 0, 40, true);
    }
    wait = 0;
  }
}



void testcolor() {
  if (cur_pos == 9) {
    strip.setPixelColor(cur_pos, 255, 100, 100);
    strip.show();
  } else if (cur_pos == 10) {
    strip.setPixelColor(cur_pos, 255, 100, 255);
    strip.show();
  } else if (cur_pos == 11) {
    strip.setPixelColor(cur_pos, 255, 255, 255);
    strip.show();
  } else if (cur_pos == 12) {
    strip.setPixelColor(cur_pos, 255, 0, 255);
    strip.show();
  } else if (cur_pos == 13) {
    strip.setPixelColor(cur_pos, 255, 0, 255);
    strip.show();
  } else if (cur_pos == 14) {
    strip.setPixelColor(cur_pos, 255, 0, 255);
    strip.show();
  } else if (cur_pos == 15) {
    strip.setPixelColor(cur_pos, 255, 0, 255);
    strip.show();
  } else if (cur_pos == 16) {
    strip.setPixelColor(cur_pos, 255, 0, 255);
    strip.show();
  } else if (cur_pos == 17) {
    strip.setPixelColor(cur_pos, 255, 255, 0);
    strip.show();
  }
}

bool Initializer = true;
void initiative() {
  if (Initializer == true) {
    delay(1050);
    for (int j = 0; j < 256; j++) {
      for (int i = 0; i < 37; i++) {
        strip.setPixelColor(i, 0, j, j);
        strip.show();
      }
    }
    for (int i = 0; i < 37; i++) {
      strip.setPixelColor(i, 0, 0, 0);
      strip.show();
    }
    for (int o = 0; o < 10; o++) {
      for (int i = -1; i < 37; i++) {
        int xp = i - 18;
        if (xp < 0) {
          xp = 37 + xp;
          strip.setPixelColor(i, 0, 255, 255);
          strip.show();
          delay(20);
          strip.setPixelColor(xp, 0, 50, 255);
          strip.show();
          delay(20);
        } else {
          strip.setPixelColor(i, 0, 255, 255);
          strip.show();
          delay(20);
          strip.setPixelColor(xp, 0, 50, 255);
          strip.show();
          delay(20);
        }
      }
    }
    for (int h = 1; h < 4; h++) {
      delay(100);
      for (int hi = 0; hi < 8; hi++) {
        for (int i = 0; i < 37; i++) {
          strip.setPixelColor(i, 0, hi * 32, 255);
          strip.show();
        }
        delay(1);
      }
    }
    for (int i = 0; i < 37; i++) {
      strip.setPixelColor(i, 0, 0, 0);
      strip.show();
    }
    strip.setPixelColor(cur_pos, 255, 0, 255);
    strip.show();
    strip.show();
    Initializer = false;
  }
}

float timer1 = 0;
int cur_save;
void buttonpanelRead() {
  if (selector == true) {
    reset();
    if (digitalRead(button_up) == HIGH) {
      cur_save = cur_pos;
      if (cur_pos - 3 > 8) {
        cur_pos = cur_pos - 3;
        strip.setPixelColor(cur_pos, 255, 0, 255);
        strip.setPixelColor(cur_save, 0, 0, 0);
        strip.show();
        delay(200);
        testcolor();
      }
    }
    if (digitalRead(button_down) == HIGH) {
      cur_save = cur_pos;
      if (cur_pos + 3 < 18) {
        cur_pos = cur_pos + 3;
        strip.setPixelColor(cur_pos, 255, 0, 255);
        strip.setPixelColor(cur_save, 0, 0, 0);
        strip.show();
        delay(200);
        testcolor();
      }
    }
    if (digitalRead(button_right) == HIGH) {
      cur_save = cur_pos;
      if (cur_pos == 9 || cur_pos == 10 || cur_pos == 12 || cur_pos == 13 || cur_pos == 15 || cur_pos == 16) {
        cur_pos = cur_pos + 1;
        strip.setPixelColor(cur_pos, 255, 0, 255);
        strip.setPixelColor(cur_save, 0, 0, 0);
        strip.show();
        delay(200);
        testcolor();
      }
    }
    if (digitalRead(button_left) == HIGH) {
      cur_save = cur_pos;
      if (cur_pos == 10 || cur_pos == 11 || cur_pos == 13 || cur_pos == 14 || cur_pos == 16 || cur_pos == 17) {
        cur_pos = cur_pos - 1;
        strip.setPixelColor(cur_pos, 255, 0, 255);
        strip.setPixelColor(cur_save, 0, 0, 0);
        strip.show();
        delay(200);
        testcolor();
      }
    }
    action = 0;
    repeater = false;
    if (digitalRead(button_ok) == HIGH) {
      for (int hqi = 0; hqi < 10; hqi++) {
        if (cur_pos == hqi + 8) {
          action = hqi;
          delay(100);
          selector = false;
        }
      }
      delay(10);
      repeater = false;
    }
    if (digitalRead(button_up) == LOW && digitalRead(button_down) == LOW && digitalRead(button_left) == LOW && digitalRead(button_right) == LOW && digitalRead(button_ok) == LOW && digitalRead(button_back) == LOW) {
      if (timer1 != 70000) {
        timer1 = timer1 + 1;
      }
      if (timer1 == 50000) {
        strip.setPixelColor(cur_pos, 50, 0, 50);
        strip.show();
      }
      if (timer1 >= 70000) {
        strip.setPixelColor(cur_pos, 0, 0, 0);
        strip.show();
      }
    } else {
      // if (digitalRead(button_up) == HIGH || digitalRead(button_down) == HIGH || digitalRead(button_left) == HIGH || digitalRead(button_right) == HIGH || digitalRead(button_ok) == HIGH || digitalRead(button_back) == HIGH) {
      timer1 = 0;
      delay(3);
      strip.setPixelColor(cur_pos, 255, 0, 255);
      strip.show();
    }
  }
}

void striprainbowGenerator(int wait, bool loop, float brightness_v3, int pixle_number_start, int pixle_number_end) {
  if (loop == 1) {
    for (int ax = 0; ax <= 88; ax++) {
      if (selector == false) {
        if (r == 255 && g == 255 && b == 255) {
          r = 255;
          g = 0;
          b = 0;
        }

        if (cnt2 == 1) {
          g = g + 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            cnt2 = 2;
            cnt = 0;
            r = 255;
            g = 255;
            b = 0;
          }
        }
        if (cnt2 == 2) {
          r = r - 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            cnt2 = 3;
            cnt = 0;
            r = 0;
            g = 255;
            b = 0;
          }
        }
        if (cnt2 == 3) {
          b = b + 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            r = 0;
            g = 255;
            b = 255;
            cnt2 = 4;
            cnt = 0;
          }
        }
        if (cnt2 == 4) {
          g = g - 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            cnt2 = 5;
            cnt = 0;
            r = 0;
            g = 0;
            b = 255;
          }
        }
        if (cnt2 == 5) {
          r = r + 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            cnt2 = 6;
            cnt = 0;
            r = 255;
            g = 255;
            b = 255;
          }
        }
        if (cnt2 == 6) {
          g = g - 31.875;
          b = b - 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            cnt2 = 7;
            cnt = 0;
            r = 255;
            g = 255;
            b = 255;
          }
        }
        if (cnt2 == 7) {
          b = b - 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            cnt2 = 8;
            cnt = 0;
            r = 255;
            g = 255;
            b = 255;
          }
        }
        if (cnt2 == 8) {
          b = b - 31.875;
          r = r - 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            cnt2 = 9;
            cnt = 0;
            r = 255;
            g = 255;
            b = 255;
          }
        }
        if (cnt2 == 9) {
          r = r - 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            cnt2 = 10;
            cnt = 0;
            r = 255;
            g = 255;
            b = 255;
          }
        }
        if (cnt2 == 10) {
          r = r - 31.875;
          g = g - 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            cnt2 = 11;
            cnt = 0;
            r = 255;
            g = 255;
            b = 255;
          }
        }
        if (cnt2 == 11) {
          g = g - 31.875;
          stop(wait);
          cnt = cnt + 1;
          if (cnt == 9) {
            cnt2 = 1;
            cnt = 0;
            r = 255;
            g = 255;
            b = 255;
          }
        }
        for (int pxn = pixle_number_start; pxn <= pixle_number_end; pxn++) {
          if (selector == false) {
            primeBrightness();
            brightness_v3 = brightness;
            strip.setPixelColor(pxn, r * brightness_v3, g * brightness_v3, b * brightness_v3);
            strip.show();
          }
        }
      } else {
        cnt = 0;
        cnt2 = 1;
        r = 255;
        g = 255;
        b = 255;
      }
    }
  } else if (loop == 0) {
    if (r == 255 && g == 255 && b == 255) {
      r = 255;
      g = 0;
      b = 0;
    }
    primeBrightness();
    if (cnt2 == 1) {
      g = g + 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        cnt2 = 2;
        cnt = 0;
        r = 255;
        g = 255;
        b = 0;
      }
    }
    if (cnt2 == 2) {
      r = r - 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        cnt2 = 3;
        cnt = 0;
        r = 0;
        g = 255;
        b = 0;
      }
    }
    if (cnt2 == 3) {
      b = b + 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        r = 0;
        g = 255;
        b = 255;
        cnt2 = 4;
        cnt = 0;
      }
    }
    if (cnt2 == 4) {
      g = g - 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        cnt2 = 5;
        cnt = 0;
        r = 0;
        g = 0;
        b = 255;
      }
    }
    if (cnt2 == 5) {
      r = r + 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        cnt2 = 6;
        cnt = 0;
        r = 255;
        g = 255;
        b = 255;
      }
    }
    if (cnt2 == 6) {
      g = g - 31.875;
      b = b - 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        cnt2 = 7;
        cnt = 0;
        r = 255;
        g = 255;
        b = 255;
      }
    }
    if (cnt2 == 7) {
      b = b - 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        cnt2 = 8;
        cnt = 0;
        r = 255;
        g = 255;
        b = 255;
      }
    }
    if (cnt2 == 8) {
      b = b - 31.875;
      r = r - 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        cnt2 = 9;
        cnt = 0;
        r = 255;
        g = 255;
        b = 255;
      }
    }
    if (cnt2 == 9) {
      r = r - 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        cnt2 = 10;
        cnt = 0;
        r = 255;
        g = 255;
        b = 255;
      }
    }
    if (cnt2 == 10) {
      r = r - 31.875;
      g = g - 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        cnt2 = 11;
        cnt = 0;
        r = 255;
        g = 255;
        b = 255;
      }
    }
    if (cnt2 == 11) {
      g = g - 31.875;
      stop(wait);
      cnt = cnt + 1;
      if (cnt == 9) {
        cnt2 = 1;
        cnt = 0;
        r = 255;
        g = 255;
        b = 255;
      }
    }
    for (int pxn = pixle_number_start; pxn <= pixle_number_end; pxn++) {
      if (selector == false) {
        primeBrightness();
        brightness_v3 = brightness;
        strip.setPixelColor(pxn, r * brightness_v3, g * brightness_v3, b * brightness_v3);
        strip.show();
      }
    }
  }
}

int R = 255;
int G = 255;
int B = 255;
int difference = 255 * brightness;  // difference between each pixel color before and after. The smaller, the more difference. 255 is default.
int previousColor_r = 255;
int previousColor_g = 255;
int previousColor_b = 255;
void random_ColorGenerator() {
  for (int ls = 0; ls < NUM_LEDS; ls++) {
    if (timer > 0.01 || timerEnabled == false) {
      primeBrightness();
      R = random(255 * brightness);
      G = random(255 * brightness);
      B = random(255 * brightness);
      if (previousColor_r + R > difference) {
        R = random(255 * brightness);
        if (previousColor_r + R > difference) {
          R = random(128 * brightness * 2);
          if (previousColor_r + R > difference) {
            R = random(64 * brightness * 4);
            if (previousColor_r + R > difference) {
              R = random(32 * brightness * 8);
              if (previousColor_r + R > difference) {
                R = random(16 * brightness * 16);
              }
            }
          }
        }
      }
      if (previousColor_g + G > difference) {
        G = random(255 * brightness);
        if (previousColor_g + G > difference) {
          G = random(128 * brightness * 2);
          if (previousColor_g + G > difference) {
            G = random(64 * brightness * 4);
            if (previousColor_g + G > difference) {
              G = random(32 * brightness * 8);
              if (previousColor_g + G > difference) {
                G = random(16 * brightness * 16);
              }
            }
          }
        }
      }
      if (previousColor_b + B > difference) {
        B = random(255 * brightness);
        if (previousColor_b + B > difference) {
          B = random(128 * brightness * 2);
          if (previousColor_b + B > difference) {
            B = random(64 * brightness * 4);
            if (previousColor_b + B > difference) {
              B = random(32 * brightness * 8);
              if (previousColor_b + B > difference) {
                B = random(16 * brightness * 16);
              }
            }
          }
        }
      }
      strip.setPixelColor(ls, R, G, B);
      strip.show();
      button_sequence();
      previousColor_r = R;
      previousColor_g = G;
      previousColor_b = B;
    }
  }
}

int potPin = 0;  // Potentiometer output connected to analog pin 3


void colorWipe(int red, int green, int blue, int wait, bool use_custom_brightness_var) {
  stop(0);
  primeBrightness();
  // Serial.println(brightness);
  if (selector == false) {
    if (use_custom_brightness_var == true) {
      for (int pixle_number = 0; pixle_number < strip.numPixels(); pixle_number++) {
        stop(0);
        if (selector == false) {
          primeBrightness();
          strip.setPixelColor(pixle_number, red * brightness, green * brightness, blue * brightness);
          strip.show();
          stop(wait);
          button_sequence();
        }
      }
    } else if (use_custom_brightness_var == false) {
      for (int pixle_number = 0; pixle_number < strip.numPixels(); pixle_number++) {
        stop(0);
        if (selector == false) {
          strip.setPixelColor(pixle_number, red, green, blue);
          strip.show();
          stop(wait);
          button_sequence();
        }
      }
    }
  }
}

void stop(float Delay) {
  int time_del = 0;
  if (time_del >= Delay) {
    if (digitalRead(button_back) == HIGH) {
      while (digitalRead(button_back) == HIGH) {
        reset();
      }
      action = 0;
      if (selector == false) {
        repeater = false;
        cur_pos = 13;
        delay(200);
        colorWipe(0, 0, 0, 0, true);
        strip.setPixelColor(cur_pos, 255, 0, 255);
        strip.show();
        selector = true;
      }
    }
  } else {
    while (Delay > 0) {
      if (digitalRead(button_back) == HIGH) {
        Delay = 0;
        action = 0;
        stop(0);
      } else {
        delay(1);
        Delay = Delay - 1;
      }
    }
  }
}

float reset_timer = 0;
void reset() {
  if (digitalRead(button_back) == HIGH) {  // If serial print is disabled, enable the delay. If delay is disabled, enable serial print.
    // Serial.println(reset_timer);
    delay(20);
    if (reset_timer > 200) {
      digitalWrite(rst_pin, LOW);
    } else {
      reset_timer = reset_timer + 1;
    }
  } else {
    reset_timer = 0;
  }
}

void primeBrightness() {
  brightness = analogRead(potPin);
  brightness = brightness / 1000;
  if (brightness > 1) {
    brightness = 1;
  }
}

void exit() {
  action = 0;
  repeater = false;
  cur_pos = 13;
  delay(200);
  for (int i = 0; i < 37; i++) {
    strip.setPixelColor(i, 0, 0, 0);
  }
  strip.setPixelColor(cur_pos, 255, 0, 255);
  strip.show();
  selector = true;
}
1 Like

Great job with code tags on your first post.

I had some difficulties with making an array, and then changing the array to something else like { 30, 5, 1 } to { 1, 5, 30 }

Can you provide a minimal, complete, example which compiles, and demonstrates your problem?

I basically want it so that when I press a button, the mode changes to the part where it checks the variable "sleep_color" and if it's one, it will set a list from { 1, 5, 30 } or { 5, 30, 5 } to { 30, 5, 1 }. I had an idea to treat the list as if it were a variable or integer, like if you had a variable (ex: "lightMode") and it was 1, then you set it to 2 or something ("lightMode = 2;") but that doesn't work the same for lists.

I did have a part in the code for the speaker that can read a list:

void runAction_speaker() {
  uint64_t myInts[] = { 200, 400, 800, 16, 1000, 1000 };  // audio input here delayed by 300 ms
  Serial.println();
  int deltym = 300;
  for (int ds = 0; ds < sizeof(myInts) / 8; ds++) {
    if (selector == false) {
      tone(speaker_pin1, myInts[ds], deltym);
      stop(deltym);
    }
  }
}

Your sketch does a bunch of fun stuff if you change the cl[] array declaration to just uint32_t cl;

        uint32_t cl[]; // This part is giving me trouble. // xfpd CHANGE to uint32_t  cl;
        for (int px = 0; px < sleep_length; px++) {
          if (sleep_color = 1) {
            cl = 1;
          }
          strip.setPixelColor(px, cl);
        }
1 Like

Hello bluebird64551

I tried to understand your description and I think that a three-dimensional field will help you.

Have a look at this little example and play around.

//https://forum.arduino.cc/t/im-trying-to-code-a-program-but-the-lists-arrays-are-being-difficult/1308712/3
#define ProjectName "I'm trying to code a program but the lists/arrays are being difficult"
#define NotesOnRelease "Arduino MEGA tested"

// make names here
enum LightMode {One, Two, Three};

// make variables here
constexpr int16_t lightModes[][3]
{
  {1, 5, 30},
  {5, 30, 5},
  {30, 5, 1},
};

void runAction_speaker(uint16_t lightModeSelected)
{
  for (uint16_t n = 0; n < sizeof(lightModes) / sizeof(lightModes[0]); n++)
  {
    Serial.print(lightModes[lightModeSelected][n]);
    Serial.print(" ");
  }
  Serial.println();
}

void setup()
{
  Serial.begin(115200);
  Serial.print("Source: "), Serial.println(__FILE__);
  Serial.print(ProjectName), Serial.print(" - "), Serial.println(NotesOnRelease);

  runAction_speaker(One);
  runAction_speaker(Two);
  runAction_speaker(Three);
}
void loop()
{

}

hth

3 Likes

This looks interesting, I will play around with it to see if I can simplify my code more. Thanks.

1 Like

I did a bit of experimenting, and implemented a new section. A bit more clarification if anyone doesn't fully understand what I'm trying to do.
Here's the new part vs. the old part:
Old:

      int red;
      int green;
      int blue;
      for (int px = 0; px < sleep_length; px++) {
        if (sleep_color == 1) {
          red = 30;  current testing
          green = 5;
          blue = 1;
        } else if (sleep_color == 2) {
          red = 5;
          green = 30;
          blue = 5;
        } else if (sleep_color == 3) {
          red = 1;
          green = 5;
          blue = 30;
        }
        strip.setPixelColor(px, red, green, blue);
        strip.setPixelColor(px + 1, 0, 0, 0);
        strip.show();
      }

New (Experimental)

      }  //Experimental start
         //https://forum.arduino.cc/t/im-trying-to-code-a-program-but-the-lists-arrays-are-being-difficult/1308712/3
#define ProjectName "I'm trying to code a program but the lists/arrays are being difficult"
#define NotesOnRelease "Arduino MEGA tested"

      // make names here
      enum LightMode { One,
                       Two,
                       Three };

      // make variables here
      constexpr int16_t lightModes[][3]{
        { 1, 5, 30 },
        { 5, 30, 5 },
        { 30, 5, 1 },
      };  // experimental end
      int red;
      int green;
      int blue;
      for (int px = 0; px < sleep_length; px++) {
        if (sleep_color == 1) {
          Serial.println(sizeof(lightModes));  //red = 30;  current testing
                                          //green = 5;
                                          //blue = 1;
        } else if (sleep_color == 2) {
          //red = 5;
          //green = 30;
          //blue = 5;
        } else if (sleep_color == 3) {
          //red = 1;
          //green = 5;
          //blue = 30;
        }
        strip.setPixelColor(px, red, green, blue);
        strip.setPixelColor(px + 1, 0, 0, 0);
        strip.show();
      }

I would like the variables (red, green, and blue) to be one variable or a list acting as three separate values to control the lights.

I think I figured how it works! The array in:

      constexpr int16_t lightModes[][3]{
        { 1, 5, 30 },
        { 5, 30, 5 },
        { 30, 5, 1 },
      };

using Serial.println(lightModes[One][2]); I got 30 as an output, when I used Serial.println(lightModes[One][0]); I got a 1.

So the first part lightModes>>[]<<[] is the layer of the array;
One = { 1, 5, 30 }
Two = { 5, 30, 5 }
Three = { 30, 5, 1 }

Here's the current progress:

  //Experimental start
         //https://forum.arduino.cc/t/im-trying-to-code-a-program-but-the-lists-arrays-are-being-difficult/1308712/3
#define ProjectName "I'm trying to code a program but the lists/arrays are being difficult"
#define NotesOnRelease "Arduino MEGA tested"

      // make names here
      enum LightMode { One,
                       Two,
                       Three };

      // make variables here
      constexpr int16_t lightModes[][3]{
        { 1, 5, 30 },
        { 5, 30, 5 },
        { 30, 5, 1 },
      };  // experimental end
      int red;
      int green;
      int blue;
      for (int px = 0; px < sleep_length; px++) {
        if (sleep_color == 1) {
          Serial.println(lightModes[One][1]);  /*red = 30;  current testing
                                          green = 5;
                                          blue = 1;*/
        } else if (sleep_color == 2) {
          /*red = 5;
          green = 30;
          blue = 5;*/
        } else if (sleep_color == 3) {
          /*red = 1;
          green = 5;
          blue = 30;*/
        }
        strip.setPixelColor(px, red, green, blue);
        strip.setPixelColor(px + 1, 0, 0, 0);
        strip.show();
      }
    }
    if (digitalRead(button_ok) == LOW && setting == 1) {
      if (digitalRead(button_up) == HIGH && sleep_color < 3) {
        delay(300);
        sleep_color = sleep_color + 1;
      } else if (digitalRead(button_down) == HIGH && sleep_color > 1) {
        delay(300);
        sleep_color = sleep_color - 1;
      }

      if (sleep_color == 1) {
        strip.setPixelColor(10, 0, 0, 0);
        strip.setPixelColor(13, 0, 0, 0);
        strip.setPixelColor(16, 255, 0, 0);
        strip.show();
      } else if (sleep_color == 2) {
        strip.setPixelColor(10, 0, 0, 0);
        strip.setPixelColor(13, 255, 255, 0);
        strip.setPixelColor(16, 255, 0, 0);
        strip.show();
      } else if (sleep_color == 3) {
        strip.setPixelColor(10, 0, 0, 255);
        strip.setPixelColor(13, 255, 255, 0);
        strip.setPixelColor(16, 255, 0, 0);
        strip.show();
      }
    }
1 Like

Good job.

The syntax of a 2d array is

data_Type array_name[n][m];

Where n is the Number of rows and m is the Number of columns.

https://www.geeksforgeeks.org/cpp-multidimensional-array/#

I did some more coding, and now it's working, but it is only blue for all three modes. I'm not sure what went wrong. Here's what I changed;

  //Experimental start
         //https://forum.arduino.cc/t/im-trying-to-code-a-program-but-the-lists-arrays-are-being-difficult/1308712/3
#define ProjectName "I'm trying to code a program but the lists/arrays are being difficult"
#define NotesOnRelease "Arduino MEGA tested"

      // make names here
      enum Color { One,
                   Two,
                   Three };

      // make variables here
      constexpr int16_t Color[][3]{
        { 30, 5, 1 },
        { 5, 30, 5 },
        { 1, 5, 30 },
      };  // experimental end
      for (int px = 0; px < sleep_length; px++) {
        if (sleep_color == 1) {
          Serial.println(Color[One][0]);
          strip.setPixelColor(px, Color[One]);
        } else if (sleep_color == 2) {
          strip.setPixelColor(px, Color[Two]);
          Serial.println(Color[One][1]);
        } else if (sleep_color == 3) {
          strip.setPixelColor(px, Color[Three]);
          Serial.println(Color[One][2]);
        }
        strip.setPixelColor(px + 1, 0, 0, 0);
        strip.show();
      }
    }

I wonder, is "n" the list number in the array?

{
{ 30, 5, 1 }
{ 5, 30, 5 }
{ 1, 5, 30 }
};

lightModes[One][0] = { **30**, 5, 1 }
lightModes[Two][0] = { 30, **5**, 1 }
lightModes[Three][0] = { 30, 5, **1** }
lightModes[One][1] = { **5**, 30, 5 }
lightModes[Two][1] = { 5, **30**, 5 }
lightModes[Three][1] = { 5, 30, **5** }
lightModes[One][2] = { **1**, 5, 30 }
lightModes[Two][2] = { 1, **5**, 30 }
lightModes[Three][2] = { 1, 5, **30** }

I wonder, is "n" the list number in the array?

Array indexing is shown here
https://www.arduino.cc/reference/en/language/variables/data-types/array/

However, the values are indexed from left to right with the left most as element 0. This is presented in the tutorial linked above. I think that your stared values represent the correct element.

int yourArray[ ] [3]
{
{ 30, 5, 1 } //row0
{ 5, 30, 5 } //row1
{ 1, 5, 30 } //row2
};
lightModes[0ne][0] = 30
lightModes[Two][0] = 5
lightModes[Three][0] = 1
lightModes[One][1] = 5
lightModes[Two][1] = 30
lightModes[Three][1] =  5
lightModes[One][2] = 1
lightModes[Two][2] = 5
lightModes[Three][2] = 30
1 Like

Or since that array happens to be square and symmetric:

int yourArray[ ] [3]
{
{ 30, 5, 1 } //row0
{ 5, 30, 5 } //row1
{ 1, 5, 30 } //row2
};

...you can think about it this way:

lightModes[One][0] = 30
lightModes[One][1] = 5
lightModes[One][2] = 1
lightModes[Two][0] = 5
lightModes[Two][1] = 30
lightModes[Two][2] = 5
lightModes[Three][0] = 1
lightModes[Three][1] =  5
lightModes[Three][2] = 30

And do somehting like:

sleepColor = One;
...
strip.setPixelColor(px,Color[sleep_color][0],Color[sleep_color][1],Color[sleep_color][2]);

It is a bit confusing with 3 configurations of 3 pixel colors. Maybe adding another enum would help clarify:

      enum PixColor { RedPx,
                   GreenPx,
                   BluePx };

...

strip.setPixelColor(px,Color[sleep_color][RedPx],Color[sleep_color][GreenPx],Color[sleep_color][BluePx]);

..and point towards expanding to more sleep_colors:

constexpr int16_t Color[][3]{
        { 30, 5, 1 }, 
        { 5, 30, 5 },
        { 1, 5, 30 },
        { 1, 2, 15 },
        { 1, 1, 7 },
        { 1, 1, 3 },
        { 1, 1, 1 },
        { 0, 0, 0 },
      };
1 Like

Originally, I was using three different variables (red, green, and blue) to set the color. The lists/arrays looked like they could be used as all three variables. In the example, it shows a single output. For the strip.setPixelColor function I need four inputs (pixel num, r, g, b) So would the array need to output a list?

I assume the outputs when calling the variable would be something like this:

lightModes[0] = { 30, 5, 1 }
lightModes[1] = { 5, 30, 5 }
lightModes[2] = { 1, 5, 30 }

I don't think the NeoPixel library function you want to use will accept the array as input. It is expecting the pixel number and the three rgb values.

/*!
  @brief   Set a pixel's color using separate red, green and blue
           components. If using RGBW pixels, white will be set to 0.
  @param   n  Pixel index, starting from 0.
  @param   r  Red brightness, 0 = minimum (off), 255 = maximum.
  @param   g  Green brightness, 0 = minimum (off), 255 = maximum.
  @param   b  Blue brightness, 0 = minimum (off), 255 = maximum.
*/
void Adafruit_NeoPixel::setPixelColor(uint16_t n, uint8_t r, uint8_t g,
                                      uint8_t b) {

  if (n < numLEDs) {
    if (brightness) { // See notes in setBrightness()
      r = (r * brightness) >> 8;
      g = (g * brightness) >> 8;
      b = (b * brightness) >> 8;
    }
    uint8_t *p;
    if (wOffset == rOffset) { // Is an RGB-type strip
      p = &pixels[n * 3];     // 3 bytes per pixel
    } else {                  // Is a WRGB-type strip
      p = &pixels[n * 4];     // 4 bytes per pixel
      p[wOffset] = 0;         // But only R,G,B passed -- set W to 0
    }
    p[rOffset] = r; // R,G,B always stored
    p[gOffset] = g;
    p[bOffset] = b;
  }
}

I think you will need to use the individual array indexes to set values for r,g,b.
@DaveX has shown you the syntax in post #13, and I'm certain that's what you were doing in code that worked as you wanted.

I'm not personally familiar with the NeoPixel library and addressing the led strips. Does using the array reference for the three values even compile?
Does .setPixelColor(number, lightMode[One] [ ]);

I'll play around with the library function and see what variations might compile, but I'm not clear you can do what you want.

EDIT:
There is a library function which will accept a uint32_t "combo" value of the rgb values.

/*!
  @brief   Set a pixel's color using a 32-bit 'packed' RGB or RGBW value.
  @param   n  Pixel index, starting from 0.
  @param   c  32-bit color value. Most significant byte is white (for RGBW
              pixels) or ignored (for RGB pixels), next is red, then green,
              and least significant byte is blue.
*/
void Adafruit_NeoPixel::setPixelColor(uint16_t n, uint32_t c) {
  if (n < numLEDs) {
    uint8_t *p, r = (uint8_t)(c >> 16), g = (uint8_t)(c >> 8), b = (uint8_t)c;
    if (brightness) { // See notes in setBrightness()
      r = (r * brightness) >> 8;
      g = (g * brightness) >> 8;
      b = (b * brightness) >> 8;
    }
    if (wOffset == rOffset) {
      p = &pixels[n * 3];
    } else {
      p = &pixels[n * 4];
      uint8_t w = (uint8_t)(c >> 24);
      p[wOffset] = brightness ? ((w * brightness) >> 8) : w;
    }
    p[rOffset] = r;
    p[gOffset] = g;
    p[bOffset] = b;
  }
}

There are several different methods you can use to combine the byte rgb values into the uint32_t for the function. There are ways to use memcpy or a union or bit shifting to combine your rgb array values into the uint32_t which the function will accept. Bit shifting or multiplication might be the most simple to understand. It's probably more complicated than using the individual array values in the function, and I'm not clear why you are trying to use the array reference instead of the individual values.

2 Likes

Or one could create a one dimensional array of the specific colors to begin with:

#include <FastLED.h>

CRGB colorSet[] = {
  CRGB( 1, 5, 30),
  CRGB( 5, 30, 5),
  CRGB( 30, 5, 1),
};

const uint32_t NumInSet = sizeof(colorSet) / sizeof(colorSet[0]);

void setup() {
  Serial.begin(115200);
  for (int ii = 0; ii < NumInSet; ++ii) {
    Serial.println(uint32_t(colorSet[ii]));
  }
}

void loop() {
}
1 Like

If my original intent was to simplify things, I could have just used straight inputs rather than trying to use variables for everything because these numbers aren't varying.

      for (int px = 0; px < sleep_length; px++) {
        if (sleep_color == 1) {
        strip.setPixelColor(px, 30, 5, 1);
        } else if (sleep_color == 2) {
        strip.setPixelColor(px, 5, 30, 5);
        } else if (sleep_color == 3) {
        strip.setPixelColor(px, 1, 5, 30);
        }
        strip.setPixelColor(px + 1, 0, 0, 0);
        strip.show();
      }

Although, now we know a bit more about arrays, so maybe we can use this knowledge to simplify or create other programs. Either way, it's working how it should, so, yay!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.