not able to resolve “a function-definition is not allowed here before '{' token"

Hi. I’m trying to make an LED animation using
arduino uno and ws2812b .

im using #include <pgmspace.h>

#include <Adafruit_NeoPixel.h>
#include “FastLED.h”

but the problem is, this message is keep coming out again and again
that i cannot able to resolve
“a function-definition is not allowed here before ‘{’ token"

Code:

void Ani1() {
//put qbert first frame

for (int passtime = 0; passtime < 2; passtime++) //display it 8 times
{
FastLED.clear();
for (int i = 0; i < NUM_LEDS; i++) {
leds = pgm_read_dword(&(Qbert01*)); //read array from flash*

* }*
* FastLED.show();*
* delay(400);*

* //put qbert second frame*
* FastLED.clear();*
* for (int i = 0; i < NUM_LEDS; i++) {
leds = pgm_read_dword(&(Qbert02)); //read array from flash*

* }*
* FastLED.show();*
* delay(400);*

* //put qbert THIRd frame*
* FastLED.clear();*
* for (int i = 0; i < NUM_LEDS; i++) {
leds = pgm_read_dword(&(Qbert03)); //read array from flash*

* }*
* FastLED.show();*
* delay(400);*
* //put qbert 4 frame*
* FastLED.clear();*
* for (int i = 0; i < NUM_LEDS; i++) {
leds = pgm_read_dword(&(Qbert04)); //read array from flash*

* }*
* FastLED.show();*
* delay(400);*

* //put qbert 5 frame*
* FastLED.clear();*
* for (int i = 0; i < NUM_LEDS; i++) {
leds = pgm_read_dword(&(Qbert05)); //read array from flash*

* }*
* FastLED.show();*
* delay(400);*

* }*

Please post the COMPLETE program code (in code tags) and also the complete error message(s). They contain lots of useful information that you've left out.

Steve

ah … :sob: :sob: i’m a beginner, so i missed that ,sorry for that…
Here’s my code (i submit it)
i was going to use button to control animations …

and the error message is

아두이노:1.8.13 (Mac OS X), 보드:“Arduino Uno”

In file included from /Users/heoseong-won/Downloads/LEDMatrixSerial_20/LEDMatrixSerial_20.ino:9:0:
/Users/heoseong-won/Documents/Arduino/libraries/FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.003

pragma message “FastLED version 3.003.003”

^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/heoseong-won/Downloads/LEDMatrixSerial_20/LEDMatrixSerial_20.ino: In function ‘void loop()’:
LEDMatrixSerial_20:501:23: error: a function-definition is not allowed here before ‘{’ token
void startShow(int i) {
^
LEDMatrixSerial_20:519:42: error: a function-definition is not allowed here before ‘{’ token
void colorWipe(uint32_t color, int wait) {
^
LEDMatrixSerial_20:527:45: error: a function-definition is not allowed here before ‘{’ token
void theaterChase(uint32_t color, int wait) {
^
LEDMatrixSerial_20:542:24: error: a function-definition is not allowed here before ‘{’ token
void rainbow(int wait) {
^
LEDMatrixSerial_20:556:36: error: a function-definition is not allowed here before ‘{’ token
void theaterChaseRainbow(int wait) {
^
LEDMatrixSerial_20:578:13: error: a function-definition is not allowed here before ‘{’ token
void Ani1() {
^
LEDMatrixSerial_20:768:1: error: expected ‘}’ at end of input
}
^
LEDMatrixSerial_20:768:1: error: expected ‘}’ at end of input
"Adafruit_NeoPixel.h"를 위한 복수개의 라이브러리가 발견되었습니다
사용됨: /Users/heoseong-won/Documents/Arduino/libraries/Adafruit_NeoPixel
사용되지 않음: /Users/heoseong-won/Documents/Arduino/libraries/Adafruit_NeoPixel-master
exit status 1
a function-definition is not allowed here before ‘{’ token

LEDMatrixSerial_20.ino (59.9 KB)

You are missing the closing brace } for this line:-

if (newState == LOW && oldState == HIGH) {

and you are missing the closing brace for this line:-

void loop() {

You are also missing the closing braces for other functions too. The Ani1(), Ani2(), Ani3() and Ani4().

Hint:- Click on a closing brace and it will tell you what the opening brace was. Or click on the opening brace and that will highlight the closing brace.

In a function definition there must be the same number of opening braces as closing ones. It not ... well you have seen what happens.

i understood and fixed that ! but,
but i still have error messages saying,

아두이노:1.8.13 (Mac OS X), 보드:“Arduino Uno”

In file included from /Users/heoseong-won/Downloads/LEDMatrixSerial_20/LEDMatrixSerial_20.ino:9:0:
/Users/heoseong-won/Documents/Arduino/libraries/FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.003

pragma message “FastLED version 3.003.003”

^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/heoseong-won/Downloads/LEDMatrixSerial_20/LEDMatrixSerial_20.ino: In function ‘void startShow(int)’:
LEDMatrixSerial_20:514:13: error: ‘Ani3’ was not declared in this scope
Ani3();
^~~~
/Users/heoseong-won/Downloads/LEDMatrixSerial_20/LEDMatrixSerial_20.ino:514:13: note: suggested alternative: ‘Ani2’
Ani3();
^~~~
Ani2
LEDMatrixSerial_20:515:13: error: ‘Ani4’ was not declared in this scope
Ani4();
^~~~
/Users/heoseong-won/Downloads/LEDMatrixSerial_20/LEDMatrixSerial_20.ino:515:13: note: suggested alternative: ‘Ani2’
Ani4();
^~~~
Ani2
/Users/heoseong-won/Downloads/LEDMatrixSerial_20/LEDMatrixSerial_20.ino: In function ‘void Ani2()’:
LEDMatrixSerial_20:685:13: error: a function-definition is not allowed here before ‘{’ token
void Ani3() {
^
LEDMatrixSerial_20:742:13: error: a function-definition is not allowed here before ‘{’ token
void Ani4() {
^
LEDMatrixSerial_20:771:1: error: expected ‘}’ at end of input
}
^

사용됨: /Users/heoseong-won/Documents/Arduino/libraries/Adafruit_NeoPixel
사용되지 않음: /Users/heoseong-won/Documents/Arduino/libraries/Adafruit_NeoPixel-master
exit status 1
‘Ani3’ was not declared in this scope

sorry to keep bothering you

LEDMatrixSerial_20.ino (59.9 KB)

i understood and fixed that ! but,,
but i still have error messages saying,

You haven't understood it because I said:-

You are also missing the closing braces for other functions too. The Ani1(), Ani2(), Ani3() and Ani4().

And you are still missing them.

Read this again:-

Hint:- Click on a closing brace and it will tell you what the opening brace was. Or click on the opening brace and that will highlight the closing brace.

If you are using the Arduino IDE, click on Tools > Auto Format, or hold down the CTRL key and press T, that will auto-format your code and you will be able to see where the code is indented improperly because of missing closing brackets.

Thank you so much :cry: :cry: :cry: There's no more error messages ! !