Read previous messages on this matter a still can't see why.
// PROJECT 3 Interactive Traffic Light
int carRed = 12; //configure traffic light
int carYellow = 11;
int carGreen = 10;
int button = 9; //pin of button
int pedRed = 8; //configure light for pedestrians
int pedGreen = 7;
int crossTime = 5000; //time for pedestrians to pass unsigned
long changeTime; //time that the button is pressed
void setup() {
//configure all LEDs as output
pinMode(carRed, OUTPUT);
pinMode(carYellow, OUTPUT);
pinMode(carGreen, OUTPUT);
pinMode(pedRed, OUTPUT);
pinMode(pedGreen, OUTPUT);
pinMode(button, INPUT); //configure button as input
digitalWrite(carGreen, HIGH); //initialize green traffic light on digitalWrite(pedRed, LOW); //initialize red pedestrian light off }
void loop() {
int state = digitalRead(button);
// test if the button is pressed and if 5 seconds have passed after it is pressed lately.
if(state == HIGH && (millis() - changeTime)> 5000){
//carry out the function of changing LED
changeLights();
}
}
void changeLights(){