int vermelhocar=13;
int amarelocar=12;
int verdecar=11;
int vermelhoped=3;
int verdeped=2;
int botao=7;
int crosstime=2000;
unsigned long mudatempo;

void setup() {
  //inicia temporizador
  mudatempo=millis();
  pinMode(vermelhocar, OUTPUT);
  pinMode(amarelocar, OUTPUT);
  pinMode(verdecar, OUTPUT);
  pinMode(vermelhoped, OUTPUT);
  pinMode(verdeped, OUTPUT);
  pinMode(botao, INPUT);

}

void loop() {
 int estado=millis(); 
 mudaestado();
 digitalWrite(vermelhocar, HIGH);
 digitalWrite(verdecar, LOW);
 digitalWrite(amarelocar, LOW);
 digitalWrite(vermelhoped, LOW);
 digitalWrite(verdeped, HIGH);
 delay(2000);
 mudaestado();
 digitalWrite(vermelhocar, LOW);
 digitalWrite(verdecar, HIGH);
 digitalWrite(amarelocar, LOW);
 digitalWrite(vermelhoped, HIGH);
 digitalWrite(verdeped, LOW);
 delay(2000);
 mudaestado();
 digitalWrite(vermelhocar, LOW);
 digitalWrite(verdecar, LOW);
 digitalWrite(amarelocar, HIGH);
 digitalWrite(vermelhoped, HIGH);
 digitalWrite(verdeped, LOW);
 delay(1000);

}

void mudaestado(){
  int estado=millis();
    if(estado==HIGH && (millis()- mudatempo)>5000){
    digitalWrite(vermelhocar, LOW);
    digitalWrite(verdecar, LOW);
    digitalWrite(amarelocar, HIGH);
    digitalWrite(vermelhoped, HIGH);
    digitalWrite(verdeped, LOW);
    delay(1000);
    digitalWrite(vermelhocar, HIGH);
    digitalWrite(verdecar, LOW);
    digitalWrite(amarelocar, LOW);
    digitalWrite(vermelhoped, LOW);
    digitalWrite(verdeped, HIGH);
    delay(2000);
    
  }
}
$abcdeabcde151015202530354045505560fghijfghij