Error code

Good afternoon

I am new to programming trying to help my son learn,

we are using a code from makeuseof.com to make a simple traffic light.

we have copied code exactly and getting error message and cant find a solution wondering if someone could point me in the right direction.

Thankyou in advance

int red = 10;
int yellow = 9;
int green = 8;
void setup() {
// put your setup code here, to run once:
void setup() {
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
}

void loop(){
changeLights();
delay(15000);
}

void changeLights(){
// green off, yellow on for 3 seconds
digitalWrite(green, LOW);
digitalWrite(yellow, HIGH);
delay(3000);

// turn off yellow, then turn red on for 5 seconds
digitalWrite(yellow, LOW);
digitalWrite(red, HIGH);
delay(5000);

// red and yellow on for 2 seconds (red is already on though)
digitalWrite(yellow, HIGH);
delay(2000);

// turn off red and yellow, then turn on green
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
delay(3000);

}

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

C:\Users\Bachy\AppData\Local\Temp\arduino_modified_sketch_539905\sketch_mar21b.ino: In function ‘void setup()’:

sketch_mar21b:6: error: a function-definition is not allowed here before ‘{’ token

void setup() {

^

sketch_mar21b:12: error: a function-definition is not allowed here before ‘{’ token

void loop(){

^

sketch_mar21b:17: error: a function-definition is not allowed here before ‘{’ token

void changeLights(){

^

sketch_mar21b:37: 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”
option enabled in File → Preferences.

Look at setup.
You've got two, one inside the other.
That's not good.

Are you certain you copied this?

Check your copying again. Are you sure the original had two lines both saying "void setup() {"?

Steve

hadnt noticed that because i was looking at the area where error code was higlighted.

Thankyou , trying again now

Adrian

Thanks guys now all working