A function definition is not allowed here before "{" token

Hi All

I keep getting this message, I know that there is a rogue curly bracket but have no idea where it is. Attached is my code, if anyone has any suggestions about how to find it would be much appreciated. I am still very much a newbie so has probably just surpassed me

void loop(){{
    ChangePalettePeriodically ();
    
    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* motion speed */
    
    FillLEDsFromPaletteColors( startIndex);
    
    FastLED.show();
    FastLED.delay(1000  UPDATES_PER_SECOND);
}

void FillLEDsFromPaletteColors( uint8_t colorIndex)

    uint8_t brightness = 255;
    
    for( int i = 0; i < NUM_LEDS; i++) {
        leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
        colorIndex += 3;
    }



// There are several different palettes of colors demonstrated here.
//
// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
//
// Additionally, you can manually define your own color palettes, or you can write
// code that creates color palettes on the fly.  All are shown here.

void ChangePalettePeriodically()
{
    uint8_t secondHand = (millis() / 1000) % 60;
    static uint8_t lastSecond = 99;
    
    if( lastSecond != secondHand) {
        lastSecond = secondHand;
        if( secondHand ==  0)  { currentPalette = RainbowColors_p;         currentBlending = LINEARBLEND; }
        if( secondHand == 10)  { currentPalette = RainbowStripeColors_p;   currentBlending = NOBLEND;  }
        if( secondHand == 15)  { currentPalette = RainbowStripeColors_p;   currentBlending = LINEARBLEND; }
        if( secondHand == 20)  { SetupPurpleAndGreenPalette();             currentBlending = LINEARBLEND; }
        if( secondHand == 25)  { SetupTotallyRandomPalette();              currentBlending = LINEARBLEND; }
        if( secondHand == 30)  { SetupBlackAndWhiteStripedPalette();       currentBlending = NOBLEND; }
        if( secondHand == 35)  { SetupBlackAndWhiteStripedPalette();       currentBlending = LINEARBLEND; }
        if( secondHand == 40)  { currentPalette = CloudColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 45)  { currentPalette = PartyColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 50)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND;  }
        if( secondHand == 55)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
    }
}

// This function fills the palette with totally random colors.
void SetupTotallyRandomPalette()
{
    for( int i = 0; i < 16; i++) {
        currentPalette[i] = CHSV( random8(), 255, random8());
    }
}

// This function sets up a palette of black and white stripes,
// using code.  Since the palette is effectively an array of
// sixteen CRGB colors, the various fill_* functions can be used
// to set them up.
void SetupBlackAndWhiteStripedPalette()
{
    // 'black out' all 16 palette entries...
    fill_solid( currentPalette, 16, CRGB::Black);
    // and set every fourth one to white.
    currentPalette[0] = CRGB::White;
    currentPalette[4] = CRGB::White;
    currentPalette[8] = CRGB::White;
    currentPalette[12] = CRGB::White;
    
}

// This function sets up a palette of purple and green stripes.
void SetupPurpleAndGreenPalette()
{
    CRGB purple = CHSV( HUE_PURPLE, 255, 255);
    CRGB green  = CHSV( HUE_GREEN, 255, 255);
    CRGB black  = CRGB::Black;
    
    currentPalette = CRGBPalette16(
                                   green,  green,  black,  black,
                                   purple, purple, black,  black,
                                   green,  green,  black,  black,
                                   purple, purple, black,  black );
}


// This example shows how to set up a static color palette
// which is stored in PROGMEM (flash), which is almost always more
// plentiful than RAM.  A static PROGMEM palette like this
// takes up 64 bytes of flash.
const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
{
    CRGB::Red,
    CRGB::Gray, // 'white' is too bright compared to red and blue
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Red,
    CRGB::Gray,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Blue,
    CRGB::Black,
    CRGB::Black
}};

You have 2x {{ at the start of loop but none here:

void FillLEDsFromPaletteColors( uint8_t colorIndex) { //<<<<<<<<<<<<<<<<<<

PS you'll need to close that missing one when you put it in.

Thank you so much for your help here. Now I am getting a different error entitled "expected initializer before ‘mainMenu’’

I have pasted the code before and cannot find where the error is. Many thanks in advance

void loop() 
  //Call the main menu.
  mainMenu();
// Calculate how long no data backet was received
unsigned long lastPacket = DMXSerial.noDataSince();

if (lastPacket < 5000) {
  // read recent DMX values and set pwm levels
  EEPROM.get (0, dmxvalue); 
 // analogWrite(RedPin, DMXSerial.read(dmxvalue));
  //analogWrite(GreenPin, DMXSerial.read(dmxvalue + 1));
  //analogWrite(BluePin,  DMXSerial.read(dmxvalue + 2));
  //analogWrite(MotorPin, DMXSerial.read(dmxvalue + 3));
 
} else {
  // Show pure red color, when no data was received since 5 seconds or more.
//  analogWrite(RedPin,   RedDefaultLevel);
//  analogWrite(GreenPin, GreenDefaultLevel);
//  analogWrite(BluePin,  BlueDefaultLevel);
//  analogWrite(MotorPin, MotorDefaultLevel);

//START OF CODE WHEN NO DMX DETECTED!!!!!!!
void loop()
    ChangePalettePeriodically ();
    
    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* motion speed */
    
    FillLEDsFromPaletteColors( startIndex);
    
    FastLED.show();
    FastLED.delay(1000  UPDATES_PER_SECOND);


void FillLEDsFromPaletteColors( uint8_t colorIndex)

    uint8_t brightness = 255;
    
    for( int i = 0; i < NUM_LEDS; i++) {
        leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
        colorIndex += 3;
    }



// There are several different palettes of colors demonstrated here.
//
// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
//
// Additionally, you can manually define your own color palettes, or you can write
// code that creates color palettes on the fly.  All are shown here.

void ChangePalettePeriodically()
{
    uint8_t secondHand = (millis() / 1000) % 60;
    static uint8_t lastSecond = 99;
    
    if( lastSecond != secondHand) {
        lastSecond = secondHand;
        if( secondHand ==  0)  { currentPalette = RainbowColors_p;         currentBlending = LINEARBLEND; }
        if( secondHand == 10)  { currentPalette = RainbowStripeColors_p;   currentBlending = NOBLEND;  }
        if( secondHand == 15)  { currentPalette = RainbowStripeColors_p;   currentBlending = LINEARBLEND; }
        if( secondHand == 20)  { SetupPurpleAndGreenPalette();             currentBlending = LINEARBLEND; }
        if( secondHand == 25)  { SetupTotallyRandomPalette();              currentBlending = LINEARBLEND; }
        if( secondHand == 30)  { SetupBlackAndWhiteStripedPalette();       currentBlending = NOBLEND; }
        if( secondHand == 35)  { SetupBlackAndWhiteStripedPalette();       currentBlending = LINEARBLEND; }
        if( secondHand == 40)  { currentPalette = CloudColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 45)  { currentPalette = PartyColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 50)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND;  }
        if( secondHand == 55)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
    }
}

// This function fills the palette with totally random colors.
void SetupTotallyRandomPalette()
{
    for( int i = 0; i < 16; i++) {
        currentPalette[i] = CHSV( random8(), 255, random8());
    }
}

// This function sets up a palette of black and white stripes,
// using code.  Since the palette is effectively an array of
// sixteen CRGB colors, the various fill_* functions can be used
// to set them up.
void SetupBlackAndWhiteStripedPalette()
{
    // 'black out' all 16 palette entries...
    fill_solid( currentPalette, 16, CRGB::Black);
    // and set every fourth one to white.
    currentPalette[0] = CRGB::White;
    currentPalette[4] = CRGB::White;
    currentPalette[8] = CRGB::White;
    currentPalette[12] = CRGB::White;
    
}

// This function sets up a palette of purple and green stripes.
void SetupPurpleAndGreenPalette()
{
    CRGB purple = CHSV( HUE_PURPLE, 255, 255);
    CRGB green  = CHSV( HUE_GREEN, 255, 255);
    CRGB black  = CRGB::Black;
    
    currentPalette = CRGBPalette16(
                                   green,  green,  black,  black,
                                   purple, purple, black,  black,
                                   green,  green,  black,  black,
                                   purple, purple, black,  black );
}


// This example shows how to set up a static color palette
// which is stored in PROGMEM (flash), which is almost always more
// plentiful than RAM.  A static PROGMEM palette like this
// takes up 64 bytes of flash.
const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
{
    CRGB::Red,
    CRGB::Gray, // 'white' is too bright compared to red and blue
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Red,
    CRGB::Gray,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Blue,
    CRGB::Black,
    CRGB::Black
}};


//END OF CODE WHEN NO DMX DETECTED!!!!!!!!

//STRIP 1
red1 = DMXSerial.read(dmxvalue);
green1 = DMXSerial.read(dmxvalue + 1);
blue1 = DMXSerial.read (dmxvalue + 2);

//STRIP 2
red2 = DMXSerial.read(dmxvalue + 3);
green2 = DMXSerial.read(dmxvalue + 4);
blue2 = DMXSerial.read (dmxvalue + 5);

//STRIP 3
red3 = DMXSerial.read(dmxvalue + 6);
green3 = DMXSerial.read(dmxvalue + 7);
blue3 = DMXSerial.read (dmxvalue + 8);

//STRIP 4

red4 = DMXSerial.read(dmxvalue + 9);
green4 = DMXSerial.read(dmxvalue +10);
blue4 = DMXSerial.read (dmxvalue + 11);

//STRIP 5

red5 = DMXSerial.read(dmxvalue +12);
green5 = DMXSerial.read(dmxvalue + 13);
blue5 = DMXSerial.read (dmxvalue + 14);

//STRIP 6

red6 = DMXSerial.read(dmxvalue +15);
green6 = DMXSerial.read(dmxvalue + 16);
blue6 = DMXSerial.read (dmxvalue + 17);

analogWrite(MotorPin, DMXSerial.read(dmxvalue + 18));
} // if
if (itemactive == 1 && currentMenuItem == 1) {
  dmxchange();
  eeprom_read_block(array, (void *) 0x20, sizeof(array));     // Calls the 'array'
  if (digitalRead(enter) == 0) {
    eeprom_write_block((void *) 0x20, array, sizeof(array));      //saves the contents of 'array' persistantly
  }

  if (digitalRead(back) == 0) {
    itemactive = 0;
    currentMenuItem = 1;
    displayMenu(currentMenuItem);
  }
/*
  { 
  //if (Serial.available())
  {
   // int speed = Serial.parseInt();
    if (speed >= 0 && speed <= 255)
    {
      analogWrite(motorPin, speed);
    }
  }
} 
*/
//Potentiometer motor
{
sensorValue = analogRead(analogInPin)/4;
outputValue = map(sensorValue, 0, 1023, 0, 255);
analogWrite(transistorPin, sensorValue);
if (sensorValue >= 160)
{
//example
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
}
else
{ digitalWrite(9, HIGH);
digitalWrite(8, LOW);
}
delay(10); }
}

if (itemactive == 1 && currentMenuItem == 2) {
  // Submenu();
  // eproom

  if (digitalRead(back) == 0) {
    itemactive = 0;
    currentMenuItem = 2;
    displayMenu(currentMenuItem);
  }
}


if (itemactive == 1 && currentMenuItem == 3) {
  // personalitly function
  if (digitalRead(back) == 0) {
    itemactive = 0;
    currentMenuItem = 3;
    displayMenu(currentMenuItem);
  }
}


//If we are out of bounds on th menu then reset it.
if (currentMenuItem < 0 || currentMenuItem > 3) {
  currentMenuItem = 0;
}

//If we have changed Index, saves re-draws.
if (state != lastState) {
  if (state == 1) {
    //If Up
    currentMenuItem = currentMenuItem - 1;
    displayMenu(currentMenuItem);
  } else if (state == 2) {
    //If Down
    currentMenuItem = currentMenuItem + 1;
    displayMenu(currentMenuItem);
  } else if (state == 3) {
    //If Selected
    selectMenu(currentMenuItem);
  }
  //Save the last State to compare.
  lastState = state;
}
delay(5);
}

//Display Menu Option based on Index.
void displayMenu(int x) {
  switch (x) {
    case 1:
      clearPrintTitle();
      lcd.print ("-> DMX");
      break;
    case 2:
      clearPrintTitle();
      lcd.print ("-> Personality");
      break;
    case 3:
      clearPrintTitle();
      lcd.print ("-> Preset");
      break;
  }
}
}
//Show the selection on Screen.


// End.
void loop()
//Call the main menu.
mainMenu();

Where does the code in the loop() function start ?

Well for a start you now have no { at the top of loop() where before you had two…

Check that each function looks like this:

returntype myFunction()
{
   //do stuff
}

edit: returntype added above, see PaulS’ post below.

Check that each function looks like this:

Functions must have return types...

PaulS: Functions must have return types...

Oh crap.... sorry

Hatzi: Thank you so much for your help here. Now I am getting a different error entitled "expected initializer before 'mainMenu''

I have pasted the code before and cannot find where the error is. Many thanks in advance

Hit Ctrl-T in Arduino IDE for autoformat. It will make it easier to visual spot extra and missing curly brackets. Functions should always start in left most position.