Hiya,
I'm working on a project I started for a local church to control WS2812B LED's using an arduino.
I've learnt enough to change colour using a 12 way rotary switch but I hope to change programs using the switch instead. I've figured out it has something to do with calling the separate .h files but I'm not a programmer... can anyone point me in the right direction?
Here is the code I have for 7 colours but I want the remaining 5 to be something like a chase, sound to light or fire effect, I have all the programs saved but I've not mastered calling them if something could offer me some advice at all? (willing to make a beer money donation for advice!)
Thanks for any help you can offer.
I'm working on a project I started for a local church to control WS2812B LED's using an arduino.
I've learnt enough to change colour using a 12 way rotary switch but I hope to change programs using the switch instead. I've figured out it has something to do with calling the separate .h files but I'm not a programmer... can anyone point me in the right direction?

Here is the code I have for 7 colours but I want the remaining 5 to be something like a chase, sound to light or fire effect, I have all the programs saved but I've not mastered calling them if something could offer me some advice at all? (willing to make a beer money donation for advice!)
Code:
// Include the FastLED library
#include <FastLED.h>
// Define the number of LEDs and the data pin
#define NUM_LEDS 32
#define DATA_PIN 6
// Define the brightness level
#define BRIGHTNESS 32
// Define the LED array
CRGB leds[NUM_LEDS];
// Define the program selection pins
#define PROGRAM_1 40
#define PROGRAM_2 41
#define PROGRAM_3 42
#define PROGRAM_4 43
#define PROGRAM_5 44
#define PROGRAM_6 45
#define PROGRAM_7 46
#define PROGRAM_8 47
#define PROGRAM_9 48
#define PROGRAM_10 49
#define PROGRAM_11 50
#define PROGRAM_12 51
// Define the program variables
int program = 0;
int lastProgram = 0;
// Setup function
void setup() {
// Set the LED data pin as output
pinMode(DATA_PIN, OUTPUT);
// Set the program selection pins as input with pullup
pinMode(PROGRAM_1, INPUT_PULLUP);
pinMode(PROGRAM_2, INPUT_PULLUP);
pinMode(PROGRAM_3, INPUT_PULLUP);
pinMode(PROGRAM_4, INPUT_PULLUP);
pinMode(PROGRAM_5, INPUT_PULLUP);
pinMode(PROGRAM_6, INPUT_PULLUP);
pinMode(PROGRAM_7, INPUT_PULLUP);
pinMode(PROGRAM_8, INPUT_PULLUP);
pinMode(PROGRAM_9, INPUT_PULLUP);
pinMode(PROGRAM_10, INPUT_PULLUP);
pinMode(PROGRAM_11, INPUT_PULLUP);
pinMode(PROGRAM_12, INPUT_PULLUP);
// Initialize the LED array
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
// Set the initial program
program = 1;
}
// Loop function
void loop() {
// Check for program selection
if (digitalRead(PROGRAM_1) == LOW) {
program = 1;
} else if (digitalRead(PROGRAM_2) == LOW) {
program = 2;
} else if (digitalRead(PROGRAM_3) == LOW) {
program = 3;
} else if (digitalRead(PROGRAM_4) == LOW) {
program = 4;
} else if (digitalRead(PROGRAM_5) == LOW) {
program = 5;
} else if (digitalRead(PROGRAM_6) == LOW) {
program = 6;
} else if (digitalRead(PROGRAM_7) == LOW) {
program = 7;
} else if (digitalRead(PROGRAM_8) == LOW) {
program = 8;
} else if (digitalRead(PROGRAM_9) == LOW) {
program = 9;
} else if (digitalRead(PROGRAM_10) == LOW) {
program = 10;
} else if (digitalRead(PROGRAM_11) == LOW) {
program = 11;
} else if (digitalRead(PROGRAM_12) == LOW) {
program = 12;
}
// Check if the program has changed
if (program != lastProgram) {
// Clear the LED array
FastLED.clear();
// Set the new program
switch (program) {
case 1:
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::White;
}
FastLED.show();
break;
case 2:
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Red;
}
FastLED.show();
break;
case 3:
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Blue;
}
FastLED.show();
break;
case 4:
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Green;
}
FastLED.show();
break;
case 5:
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Yellow;
}
FastLED.show();
break;
case 6:
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Cyan;
}
FastLED.show();
break;
case 7:
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Purple;
}
FastLED.show();
break;
case 8:
// Program 8 code here
break;
case 9:
// Program 9 code here
break;
case 10:
// Program 10 code here
break;
case 11:
// Program 11 code here
break;
case 12:
// Program 12 code here
break;
}
// Show the new LED array
FastLED.show();
// Update the last program variable
lastProgram = program;
}
}
Thanks for any help you can offer.