Traffic light with manual buttons to show states

Hi All Im a Teacher at a nursery, i have an old traffic light i would like to rig up to the arduino to control, to teach the children about road saftey and crossings, i would like to know the right way to achieve my goal, i would like 3 buttons connected, one for each coloured led so thats green, amber and red.

amber always flashes when active red always flashes when active green always solid on when active

when a button is pushed it turns off current selection and shows desired colour

ive got as far as writing this as a simple on or off when button is pushed, could this be modified?

thank for reading

//The circuit * LED attached from pin 3,5,6 to ground
// pushbutton attached from pin 2,4,7 to +5V
//10K resistor attached from pin 2,4,7 to ground






const int buttonPin1= 2;    // the number of the pushbutton pin
const int buttonPin2= 4;
const int buttonPin3= 7;
const int ledPin1= 5;      // green led pin
const int ledPin2= 6;      // yellow led pin
const int ledPin3= 3;      // red led pin


// Variables will change:
int ledState1 = LOW;         // the current state of the output pin
int buttonState1;             // the current reading from the input pin
int lastButtonState1 = HIGH;   
int ledState2 = LOW;         
int buttonState2;             
int lastButtonState2 = HIGH;   
int ledState3 = LOW;        
int buttonState3;             
int lastButtonState3 = HIGH;   


// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup() {
  pinMode(buttonPin1, INPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(buttonPin2, INPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(ledPin3, OUTPUT);

  

  // set initial LED state
  digitalWrite(ledPin1, ledState1);
  digitalWrite(ledPin2, ledState2);
  digitalWrite(ledPin3, ledState3);
  
}

void loop() {
  // read the state of the switch into a local variable:
  int reading = digitalRead(buttonPin1);

  // check to see if you just pressed the button 
  // (i.e. the input went from LOW to HIGH),  and you've waited 
  // long enough since the last press to ignore any noise:  

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState1) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  } 
  
  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState1) {
      buttonState1 = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState1 == HIGH) {
        ledState1 = !ledState1;

      }
    }
  }
  
  // set the LED:
  digitalWrite(ledPin1, ledState1);
  
  
  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
  lastButtonState1 = reading;

  // next button
  
    // read the state of the switch into a local variable:
  int reading2 = digitalRead(buttonPin2);

  // check to see if you just pressed the button 
  // (i.e. the input went from LOW to HIGH),  and you've waited 
  // long enough since the last press to ignore any noise:  

  // If the switch changed, due to noise or pressing:
  if (reading2 != lastButtonState2) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  } 
  
  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading2 != buttonState2) {
      buttonState2 = reading2;

      // only toggle the LED if the new button state is HIGH
      if (buttonState2 == HIGH) {
        ledState2 = !ledState2;
      }
    }
  }
  
  // set the LED:
  digitalWrite(ledPin2, ledState2);
  
  
  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
  lastButtonState2 = reading2;
  
  //next button
  
    // read the state of the switch into a local variable:
  int reading3 = digitalRead(buttonPin3);

  // check to see if you just pressed the button 
  // (i.e. the input went from LOW to HIGH),  and you've waited 
  // long enough since the last press to ignore any noise:  

  // If the switch changed, due to noise or pressing:
  if (reading3 != lastButtonState3) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  } 
  
  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading3 != buttonState3) {
      buttonState3 = reading3;

      // only toggle the LED if the new button state is HIGH
      if (buttonState3 == HIGH) {
        ledState3 = !ledState3;
      }
    }
  }
  
  // set the LED:
  digitalWrite(ledPin3, ledState3);
  
  
  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
  lastButtonState3 = reading3;
}

amber always flashes when active red always flashes when active

In what part of the world? Not in the USA.

  if (reading != lastButtonState1) {

Using names that seem to bear no relationship to each other does not make sense. Imagine how much easier this would be to understand if it was:

  if (currState1 != lastState1)
  {

ive got as far as writing this as a simple on or off when button is pushed, could this be modified?

Sure. But, the code does something. You have not explained what it does. What it does differs from what you want, or there would be no need to modify it, but you have not explained how it differs.

This compiles but does not work correctly, how would I allocate buttons to switch specific LEDs turning off last when button is pushed ? Thanks

This compiles but does not work correctly

It does something. Feel free to tell us what that is. You want it to do something different. Feel free to describe how what it does differs from what you want.

Or, feel free to deal with the problem, whatever it is, yourself.