// Button press cycle
buttonValue = !digitalRead(buttonPin); // Read input value and store it in value
if (buttonValue != buttonState) { // The button state has changed
if (buttonValue == 0) { // Check if button is pressed
if (patternProgram == 0) { // If set to smooth logarithmic mapping
patternProgram = 1; // Switch to stepped chromatic mapping
}
else {
if (patternProgram == 1) {
patternProgram = 2; // Switch to next mode
}
else {
if (patternProgram == 2) {
patternProgram = 3;
}
else {
if (patternProgram == 4) {
patternProgram = 5;
}
else {
if (patternProgram == 5) {
patternProgram = 0;
}
}
}
}
}
}
}
buttonState = buttonValue; // Save the new state in your value
}
switch (patternProgram) {
case 0:
void loop() {
for(int dot = 0; dot < NUM_LEDS; dot++) {
leds[dot] = CRGB::Blue;
FastLED.show();
// Clear this led for the next time around the loop
leds[dot] = CRGB::Black;
delay(30);
break;
}
}
}
and debugger from arduino says me error, like:
75:1: error: expected unqualified-id before 'switch'
Can somebody explain or correct the mistake? And why it happens?
your function loop endsd before the switch statement so switch is in no function.
Also note that you are not allowed to write a function implementation inside of a function.
put that switch in a function and delete the void loop() and it's brackets like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void switcher(int patternProgram)
{
switch (patternProgram)
{
case 0:
for(int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Blue;
FastLED.show();
// Clear this led for the next time around the loop
leds[dot] = CRGB::Black;
delay(30);
}
break;
}
}