i am using a key pad to control some led strips, it all works ok but i need case 2 to repeat until i select another case but i am struggling to find a way that works
#include <Keypad.h>
#include <FastLED.h>
#define NUM_LEDS 20
#define NUM_STRIPS 2
int Speed = 15;
const byte ROWS = 4;
const byte COLS = 4;
CRGB dreamHead [NUM_LEDS];
char Keys [ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad customKeypad = Keypad(makeKeymap(Keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
char customKey = customKeypad.getKey();
FastLED.addLeds<NEOPIXEL, 13>(dreamHead, NUM_LEDS);
FastLED.addLeds<NEOPIXEL, 12>(dreamHead, NUM_LEDS);
if (customKey) {
Serial.println(customKey);
}
fill_solid(dreamHead, NUM_LEDS, CRGB(0, 0, 0));
FastLED[1].showLeds();
fill_solid(dreamHead, NUM_LEDS, CRGB(0, 0, 0));
FastLED[2].showLeds();
}
void fadeall() {
for (int i = 0; i < NUM_LEDS; i++) {
dreamHead[i].nscale8(200);
}
}
void loop () {
switch (customKeypad.getKey())
{
case '1':
turnOn();
break;
case '2':
startDream();
break;
case '0':
turnOff();
break;
}
}
void turnOn() {
fill_solid(dreamHead, NUM_LEDS, CRGB(0, 255, 0));
FastLED[1].showLeds();
fill_solid(dreamHead, NUM_LEDS, CRGB(0, 255, 0));
FastLED[2].showLeds();
}
void startDream () {
fill_solid(dreamHead, NUM_LEDS, CRGB(0, 255, 0));
FastLED[1].showLeds();
for (int i = 0; i < NUM_LEDS; i++) {
dreamHead[i] = CRGB::Indigo;
FastLED[2].showLeds();
fadeall();
delay(Speed);
}
}
void turnOff() {
fill_solid(dreamHead, NUM_LEDS, CRGB(0, 0, 0));
FastLED.show();
}