Traffic light

Hello, im new to arduino and trying to make a simple traffic light with LEDs. My goal is to make it so that at the push of a button the traffic light starts and keeps going until it is stopped with another push of the same button. I have been successful in doing the first part but once it starts it seems to be stuck in a loop. I tried to fix it so that a counter of the button presses will stop it and then reset to 0. My code is as follows:

//Variables constantes const int Boton=1; //pin del boton const int Azul=2; //pin led azul const int Rojo=3; //pin led rojo const int Verde=4; //pin led rojo //Variables cambiantes int Conteo=0; int Estado=0; int Estadopasado=0; void setup() { pinMode(Boton, INPUT); pinMode(Azul, OUTPUT); pinMode(Rojo, OUTPUT); pinMode(Verde, OUTPUT); } void loop() { ContarBoton(); Semaforo(); Apagar(); } void ContarBoton(){ Estado=digitalRead(Boton); //leer boton if(Estado!=Estadopasado){ if(Estado==HIGH){ Conteo++; delay(50); } } } void Semaforo(){ if(Conteo==1){ digitalWrite(Verde, HIGH); delay(1000); digitalWrite(Azul, HIGH); delay(500); digitalWrite(Azul, LOW); digitalWrite(Verde, LOW); digitalWrite(Rojo, HIGH); delay(1000); digitalWrite(Rojo, LOW); } }

void Apagar(){ if(Conteo ==2){ digitalWrite(Azul, LOW); digitalWrite(Rojo, LOW); digitalWrite(Verde, LOW); Conteo=0; } else{ } }

Is this an Introductory Tutorial? I don't think so.

Please read https://forum.arduino.cc/index.php?topic=148850.0 and pay special attention to point #7 about posting code.

Next edit your post and include the code tags.

Are you using a pull-up or pull-down resitor for the button?

In the below code, you don't update Estadopasado so it will always be 0

void ContarBoton() {
  Estado = digitalRead(Boton); //leer boton
  if (Estado != Estadopasado) {
    if (Estado == HIGH) {
      Conteo++;
      delay(50);
    }
  }
}