Expected primary-expression before ')' token

Hi,
I have a problem with this :
“expected primary-expression before ‘)’ token”
Help me please
Thanks

Your error is not shown in that image.

Please paste your entire sketch here as it looks like youre missing a bracket somewhere.

1 Like

Okay

    BLYNK_WRITE(V2) {
    if (param.asInt()) {
    game = 2;
    rainbow(uint8_t); // Rainbow
    }
    else {
    }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////
    void loop()
    {
    Blynk.run();
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////
    void rainbow(uint8_t wait) {
    uint16_t i, j;
    for(j=0; j<256; j++) {
     for(i=0; i<NUMPIXELS; i++) {
      pixels.setPixelColor(i, Wheel((i+j) & 255));
     }
    pixels.show();
    delay(wait);
    }
    // delay(1);
    }
    uint32_t Wheel(byte WheelPos) {
    WheelPos = 255 - WheelPos;
    if(WheelPos < 85) {
    return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
    }
    if(WheelPos < 170) {
    WheelPos -= 85;
    return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
    }
    WheelPos -= 170;
    return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);

@mshey904 That is not the entire sketch.

1 Like

I think the error is in this line:

There’s no expression in the if statement before the closing bracket.
It should look something like this:
if (param.asInt()==1) {

Pete.

Incorrect, this abbreviation is fine as both are the same and both are TRUE

if (param.asInt()) {

Entire sketch… top to bottom… Select All… Paste.

1 Like

C:\Users\V\Desktop\folder\blynk_neopixel_without_brightness\blynk_neopixel_without_brightness.ino: In function ‘void BlynkWidgetWrite2(BlynkReq&, const BlynkParam&)’:

blynk_neopixel_without_brightness:28: error: expected primary-expression before ‘)’ token

 rainbow(uint8_t); // Rainbow

                ^

Multiple libraries were found for “Adafruit_NeoPixel.h”
Used: C:\Users\V\Documents\Arduino\libraries\Adafruit_NeoPixel
Not used: C:\Program Files (x86)\Arduino\libraries\Adafruit_NeoPixel
Multiple libraries were found for “BlynkSimpleEsp8266.h”
Used: C:\Users\V\Documents\Arduino\libraries\blynk-library-0.4.7
Not used: C:\Users\V\Documents\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Not used: C:\Users\V\Documents\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Not used: C:\Users\V\Documents\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Not used: C:\Users\V\Documents\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
exit status 1
expected primary-expression before ‘)’ token

Dude… the sketch.

I’m so sorry
Is it true?

#include <Adafruit_NeoPixel.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h>
#define PIN D1
#define NUMPIXELS 597
int red = 0;
int green = 0;
int blue = 0;
int game = 0;
  Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
///////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  Blynk.begin("d410a13b55560fbdfb3df5fe2a2ff5", "8", "12345670");
  pixels.begin();
  pixels.show();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
BLYNK_WRITE(V1) {
  game = 1;
  int R = param[0].asInt();
  int G = param[1].asInt();
  int B = param[2].asInt();
  setSome(R, G, B);
}
BLYNK_WRITE(V2) {
  if (param.asInt()==1) {
    game = 2;
    rainbow(uint8_t); // Rainbow
  }
  else {
  }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{
Blynk.run();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
void rainbow(uint8_t wait) {
  uint16_t i, j;
  for(j=0; j<256; j++) {
    for(i=0; i<NUMPIXELS; i++) {
      pixels.setPixelColor(i, Wheel((i+j) & 255));
    }
    pixels.show();
    delay(wait);
  }
 // delay(1);
}
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}BLYNK_WRITE(V3) {
  if (param.asInt()) {
    game = 3;
    setAll(125, 47, 0); //candle
  }
  else {
  }
}
BLYNK_WRITE(V4) {
  game = 4;
  int Bright = param.asInt();
  pixels.setBrightness(Bright);
  pixels.show();
}
BLYNK_WRITE(V5) {
  if (param.asInt()) {
    game = 5;
    setAll(85, 0, 255);
  }
  else {
  }
}
BLYNK_WRITE(V6) {
  if (param.asInt()) {
    game = 6;
    oFF(red, green, blue);
//    fullOff();
  }
  else {
  }
}
BLYNK_WRITE(V7) {
  if (param.asInt()) {
    game = 7;
    setAll(255, 0, 85);
  }
  else {
  }
}
BLYNK_WRITE(V8) {
  if (param.asInt()) {
    game = 8;
    setAll(90, 90, 90);
  }
  else {
  }
}
BLYNK_WRITE(V9) {
  if (param.asInt()) {
    game = 9;
    setAll(255, 130, 130);
  }
  else {
  }
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////
void oFF(byte r, byte g, byte b) {
  if (game == 1) {
    offsome(r, g, b);
  }
  else if (game == 2) {
    offall(r, g, b);
  }
  else if (game == 3) {
    offall(r, g, b);
  }
  else if (game == 4) {
    offall(r, g, b);
  }
  else if (game == 5) {
    offall(r, g, b);
  }
  else if (game == 6) {
    offall(r, g, b);
  }
  else if (game == 7) {
    offall(r, g, b);
  }
  else if (game == 8) {
    offall(r, g, b);
  }
  else if (game == 9) {
    offall(r, g, b);
  }
}

void offall(byte r, byte g, byte b) {
  uint32_t x = r, y = g, z = b;
  for (x; x > 0; x--) {
    if( y > 0 )
      y--;
    if( z > 0 )
      z--;
    for(int i = 0; i < NUMPIXELS; i++ ) {
      pixels.setPixelColor(i, pixels.Color(x, y, z));
    }
    pixels.show();
    delay(0);
  }
  //delay(0);
}

void offsome(byte r, byte g, byte b) {
  uint32_t x = r, y = g, z = b;
  for (x; x > 0; x--) {
    if( y > 0 )
      y--;
    if( z > 0 )
      z--;
    for(int i = 87; i < 214; i++ ) {
      pixels.setPixelColor(i, pixels.Color(x, y, z));
    }
    for(int i = 385; i < 510; i++ ) {
      pixels.setPixelColor(i, pixels.Color(x, y, z));
    }
    pixels.show();
    delay(0);
  }
}
void setAll(byte r, byte g, byte b) {
  uint16_t x = 0, y = 0, z = 0;
  for (x; x < r; x++) {
    if( y < g )
      y++;
    if( z < b )
      z++;
    for(int i = 0; i < NUMPIXELS; i++ ) {
      pixels.setPixelColor(i, pixels.Color(x, y, z));
    }
    pixels.show();
    red = r;
    green = g;
    blue = b;
    delay(0);
  }
  //delay(0);
}

void setSome(byte r, byte g, byte b) {
  uint16_t x = 0, y = 0, z = 0;
  for (x; x < r; x++) {
    if( y < g )
      y++;
    if( z < b )
      z++;
    for(int i = 86; i < 212; i++ ) {
      pixels.setPixelColor(i, pixels.Color(x, y, z));
    }
    for(int i = 385; i < 512; i++ ) {
      pixels.setPixelColor(i, pixels.Color(x, y, z));
    }
    pixels.show();
    red = r;
    green = g;
    blue = b;
    delay(0);
  }
  //delay(0);
}

void fullOff() {
  for(int i = 0; i < NUMPIXELS; i++ ) {
    pixels.setPixelColor(i, pixels.Color(0, 0, 0));
  }
    pixels.show();
}

Yup, just edited it and formatted the code to make it easier to read on here. Take a look at your post to see how I’ve done it for next time you post your code.

Give me a min to look at your code. I have no IDE here to compile so I will only be able to look through it.

@Gunner on the other hand im sure will be able to help find the missing bracket.

Edit, @mshey904, you are basically making an LED controller? Take a look at my Blynk Pixel LED Controller. I doesnt use the old and outdated Neopixel library, instead using the FastLED lib.

2 Likes

Work, work, work… all I hear is Cinderfella… :stuck_out_tongue:

I actually don’t know the reason yet… brain too foggy today…

But this is the compiled error

sketch_sep13a:28: error: expected primary-expression before ')' token

     rainbow(uint8_t); // Rainbow

                    ^

exit status 1
expected primary-expression before ')' token
2 Likes

the problem is here. the rainbow function expects a variable, but gots only uint8_t, which is not variable.

edit: code formatted

1 Like

so should I do to fix it?

  1. the rainbow function expects an argument to work. there is no variable passed to that function, this is why it gives that error.

  2. in the long term, you should learn at least the basic coding principles, not just copy/pasting code.

8 posts were split to a new topic: Unclarified issue