LED Traffic Light with push button

The code I have written up is giving me problems. It won't verify. Any advice would be appreciated. This code is taken from Arduino Programming for Beginners: Traffic Light Controller Project Tutorial slightly modified.

int button = 2; // switch is on pin 2
int buttonValue = 0; // switch defaults to 0 or LOW

int red = 13;
int yellow = 12;
int green = 11;

void setup(){
pinMode(red,OUTPUT);
pinMode(yellow,OUTPUT);
pinMode(green,OUTPUT);
pinMode(switch,INPUT);
digitalWrite(green,HIGH);
}
void loop(){
// read the value of the switch
switchValue = digitalRead(button);
// if the switch is HIGH, ie. pushed down - change the lights!
if (buttonValue == HIGH){
changeLights();
delay(15000); // wait for 15 seconds
}
}

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

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

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

ERROR:
sketch_mar27a.ino: In function 'void setup()':
sketch_mar27a:12: error: expected primary-expression before 'switch'
sketch_mar27a.ino: In function 'void loop()':
sketch_mar27a:17: error: 'switchValue' was not declared in this scope

Hi,

pinMode(switch,INPUT);

It looks like you cannot use switch as a variable name, it is a function name
I think you mean button .

switchValue = digitalRead(button);

I think you mean buttonValue .

Tom..... :slight_smile: