-2

Could someone point out what exactly I'm screwing up here and provide a specific solution. Here's the error message:

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"


sketch_jul24g:38:11: error: expected ')' before '(' token
 (  pinMode(led, OUTPUT);     )
           ^

sketch_jul24g:38:30: error: expected unqualified-id before ')' token
 (  pinMode(led, OUTPUT);     )
                              ^

sketch_jul24g:39:1: error: expected declaration before '}' token
 }
 ^

exit status 1

expected ')' before '(' token


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

And here's the code:

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN        6 // On Trinket or Gemma, suggest changing this to 1

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 16 // Popular NeoPixel ring size

// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 0 // Time (in milliseconds) to pause between pixels

 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {   
  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  // END of Trinket-specific code.

  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}
             
  // initialize the digital pin as an output.
(  pinMode(led, OUTPUT);     )
}

// the loop routine runs over and over again forever:
void loop() {
   pixels.clear(); // Set all pixel colors to 'off'

  // The first NeoPixel in a strand is #0, second is 1, all the way up
  // to the count of pixels minus one.
  for(int i=0; i<NUMPIXELS; i++) { // For each pixel...

    // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    // Here we're using a moderately bright green color:
    pixels.setPixelColor(i, pixels.Color(255, 255, 255));

    pixels.show();   // Send the updated pixel colors to the hardware.

    delay(DELAYVAL); // Pause before next pass through loop
  }
  pixels.setPixelColor(i, pixels.Color(255, 255, 255)); // turn the LED on (HIGH is the voltage level)
  delay(3);               // wait for a second
  pixels.setPixelColor(i, pixels.Color(0, 0, 0));    // turn the LED off by making the voltage LOW
  delay(8000);               // wait for a second
}

Like I said-what's going on? Thanks!

  • examine example code that is included with the Arduino IDE ... pay attention when you are looking at the code – jsotola Jul 25 at 1:39
  • Please pay attention when structuring your code and try to understand what opening and closing braces { } and parentheses ( ) are used for in C++. – StarCat Jul 25 at 6:21
1

Why did you put parenthesis around that line? If you take them off the code will compile.

  // initialize the digital pin as an output.
(  pinMode(led, OUTPUT);     )

should be:

  // initialize the digital pin as an output.
  pinMode(led, OUTPUT); 
| improve this answer | |
  • Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno" sketch_jul24g:38:9: error: expected constructor, destructor, or type conversion before '(' token pinMode(led, OUTPUT); ^ sketch_jul24g:39:1: error: expected declaration before '}' token } ^ exit status 1 expected constructor, destructor, or type conversion before '(' token This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences. This the error I get after eliminating the parentheses. – joeysupercool Jul 25 at 1:57
  • you have unmatched braces ... your code is not properly indented so it is difficult to see things like unmatched braces ... look at example code in the Arduino IDE ... your code should be formatted the same way – jsotola Jul 25 at 3:46
  • Press control-T in the IDE and it will line up your blocks. This isn't a free error correcting service. If you have some questions about how to code then ask them. Please don't just post your error message hoping someone will work it out for you. – Delta_G Jul 25 at 4:04
  • Got it, thanks. – joeysupercool Jul 25 at 10:29
0

use { pinMode(led, OUTPUT); } to create a new scope and if you don't need new scope just remove (, )

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.