Was not declared in this scope

I'm quite new to arduino and I keep running into a problem.

I get the following error message: 'rainbowCycle' was not declared in this scope

Below is my (compiled) code. Could you help me in figuring out where I am missing something? Thank you in advance.

#include <FastLED.h>
#define NUM_LEDS 9
#define DATA_PIN 4
#define LED_PIN 4
#define BRIGHTNESS 64
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB

CRGB leds[NUM_LEDS];

void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);

delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
}

void loop() {

leds[0] = CRGB::Green;
FastLED.show();
delay(3000);

leds[1] = CRGB::Green;
FastLED.show();
delay(3000);

leds[2] = CRGB::Green;
FastLED.show();
delay(3000);

leds[3] = CRGB::Green;
FastLED.show();
delay(3000);

leds[4] = CRGB::Green;
FastLED.show();
delay(3000);

leds[5] = CRGB::Green;
FastLED.show();
delay(3000);

leds[6] = CRGB::Green;
FastLED.show();
delay(3000);

leds[7] = CRGB::Green;
FastLED.show();
delay(3000);

leds[8] = CRGB::Green;
FastLED.show();
delay(3000);

for (int i = 0; i < 9; i++) {
leds = CRGB::Green;

  • FastLED.show();*
    _ leds = CRGB::Black;_
    * delay(100);*
    * }*
    {
    * randomSeed(millis());*
    * int wait=random(10,30);*
    * int dim=random(4,6);*
    * int max_cycles=8;
    int cycles=random(1,max_cycles+1);
    _
    rainbowCycle(wait, cycles, dim);_
    _
    }_
    void rainbowCycle(int wait, int cycles, int dim) {
    _
    //loop several times with same configurations and same delay*_
    * for(int cycle=0; cycle < cycles; cycle++){*
    * byte dir=random(0,2);*
    * int k=255;*
    * //loop through all colors in the wheel*
    * for (int j=0; j < 256; j++,k--) {*
    * if(k<0) {*
    * k=255;*
    * }*
    * //Set RGB color of each LED*
    * for(int i=0; i<NUM_LEDS; i++) {
    CRGB ledColor = wheel(((i * 256 / NUM_LEDS) + (dir==0?j:k)) % 256,dim);
    _ leds=ledColor;
    }
    FastLED.show();
    FastLED.delay(wait);
    }
    }
    }
    CRGB wheel(int WheelPos, int dim) {
    CRGB color;
    if (85 > WheelPos) {
    color.r=0;
    color.g=WheelPos * 3/dim;
    color.b=(255 - WheelPos * 3)/dim;;
    }
    else if (170 > WheelPos) {
    color.r=WheelPos * 3/dim;
    color.g=(255 - WheelPos * 3)/dim;
    color.b=0;
    }
    else {
    color.r=(255 - WheelPos * 3)/dim;
    color.g=0;
    color.b=WheelPos * 3/dim;
    }
    return color;
    }*_

}

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is the forum software can interpret parts of your code as markup (for example, the italics in your code above), leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar, then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

You have an extra opening brace in your loop function that causes the rainbowCycle definition to be inside the loop function, thus the error.

A very helpful troubleshooting tool is the Auto Format feature (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor). If you do an Auto Format and then compare the resulting indentation to your intended program structure, it will quickly point you to where there is a missing or extra brace.

Another useful feature of the Arduino IDE/Arduino Web Editor is that when you place the cursor next to one bracket, it puts a box around the matching bracket. If the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.