Errors compiling need advice with editing.

Ive spent 2 days trying to edit the errors out of this code. It says I have something wrong with the {}.
Ive moved the { to after void commands, and get more errors.
Im just looking for a motor to sweep.
A heartbeat type led, and too flash a relay on, and off using a transistor, resistor, and diode on pin 11.
If anyone can help with some advice for this small program.

Error codes;
sketch_apr05a.ino:91:1: error: a function-definition is not allowed here before ‘{’ token
sketch_apr05a.ino:101:1: error: expected ‘}’ at end of input
sketch_apr05a.ino:101:1: error: expected ‘}’ at end of input
Error compiling.

Code.

// Sweep
// by BARRAGAN http://barraganstudio.com
// This example code is in the public domain.

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.

This example code is in the public domain.
*/

// 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 loop () {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);

// the loop routine runs over and over again forever:

digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(400); // wait for 400ms
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for 100ms
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for 500ms
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(30000); // wait for 30 second
}
/*

Blink

Turns on an LED on for one second, then off for one second, repeatedly.

This example code is in the public domain.

*/

// Pin 11 has an LED connected on most Arduino boards.

// give it a name:

int led = 11;
{

// initialize the digital pin as an output.

pinMode(led, OUTPUT);

// the loop routine runs over and over again forever:

void loop ()
{

digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(led, LOW); // turn the LED off by making the voltage LOW

delay(1000); // wait for a second

}

First of all… you have 3 loop() functions ! That is not possible…
Then … do not use delay() to blink LEDs - use BlinkWithOutDelay example to see how it can be done.
And… put your code in code tags before posting it on forum.

Try this :

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
int led = 13;
int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  pinMode(led, OUTPUT);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
 
 
void loop() 
{ 
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
}

Instead of writing random nonsense, when you don't know what you are doing, get a decent textbook or find an online tutorial and learn programming syntax properly.

You have two loop( ) functions. That is probably your problem.

The compiler is telling you that it doesn't like line 91 or 101. A good place to start looking.

Okay thanks that helped i'm down to one error now. Does this ino # represent any particular area in the code? I know its not a line #.

ino:22:1: error: expected unqualified-id before '{' token Error compiling.

Thanks for taking the time to help im new to coding, and I just found Linux, and Arduino. Open source has been teaching me a lot the last week. My life just changed.

That means line 22 character 1.

Post the revised code. Sometimes the place where the compiler gives up isn't the exact same place the mistake is.

ino:22:1:

"ino" is part of the file name for the source code file with the error. The compiler doesn't like line 22, and it doesn't like it near the first character in the line.

This is not a precise guide to the actual location of the error. Often, you can make a syntax mistake and the compiler will continue for a line or two or ( rarely ) more, before it realises that it cannot interpret what you wrote correctly. But it's a good place to start looking.

Most code editors have some way of finding line 22, I can count that many lines just looking at the screen. Line 101 is too many for that.

ino:22:1: error: expected unqualified-id before '{' token Error compiling.

This means, that your missing one } or you have too many { characters.

Number of { in the code has to match numbers of }

For example :

setup()
{

}

loop ()
{

if (something )

{
do_something;
do_something_else;
}

}

If you delete one } , you'll get an error :

setup()
{

}

loop ()
{

if (something )

{
do_something;
do_something_else;
                                    // missing } here 

}

Quick tip for you : in Arduino IDE, if you place a cursor just after { character, IDE will highlight corresponding } character and vice versa. This way you can check what you're missing.