a function-definition is not allowed here before '{' token HELP

hi guys im a bit new to this and i got a few problems with my code. i have been trying to look up my error but i cant find it :frowning: here is my code

#include <Servo.h>

void setup() {
// put your setup code here, to run once:
Servo myservo;

int pos = 0;{

myservo.attach(10) ;{

}

void loop() {

// put your main code here, to run repeatedly:
//for (pos = 0; pos <= 180; pos +=1) {

myservo.write(pos) ;
delay(15) ;
}

here is my full error code

Arduino: 1.6.7 (Windows 10), Board: “Arduino/Genuino Uno”

C:\Users\Tobis\Desktop\sketch_dec25a\sketch_dec25a.ino: In function ‘void setup()’:

sketch_dec25a:15: error: a function-definition is not allowed here before ‘{’ token

void loop() {

^

sketch_dec25a:23: error: expected ‘}’ at end of input

}

^

sketch_dec25a:23: error: expected ‘}’ at end of input

exit status 1
a function-definition is not allowed here before ‘{’ token

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.

you have a mess of braces in setup()

you need t have them in matching pairs

void setup()
{
  //
}

using the IDE's auto format feature would be of assistance for you:

TOOLS
AUTO FORMAT

void setup() {
  // put your setup code here, to run once:
Servo myservo;

int pos = 0;{


 myservo.attach(10) ;{
  
 }

3 {{{ but only 1 }, they need to match up. Or get rid of the extra, the 2nd & 3rd aren't doing anything for you.

Same within loop(), 2 {{ and only 1 }

And the Servo syntax is not quite correct, it is generally like this:

#include <Servo.h>
Servo myservo;
void setup() {
  // put your setup code here, to run once:

  int pos = 0;

  myservo.attach(10) ;
}

void loop() {
  // put your main code here, to run repeatedly:
  for (int pos = 0; pos <= 180; pos=pos+1) {

    myservo.write(pos) ;
    delay(15) ;
  }
}

Wh{y so m{any bra{ces? The problem here is that you don't actually know what they are for. Google for a tutorial on basic C/C++ syntax.

Actually, this is point #1 in the sticky post "read this before posting a programming question". You will achieve nothing by attempting to program by copy/pasting code you don't understand.