//Not Working



// Define the pins for the traffic light LEDs
const int redPin = 2;     // Red LED
const int yellowPin = 4;  // Yellow LED
const int greenPin = 5;   // Green LED

// Define the pin for the push button
const int buttonPin = 18;

// Define the state of the traffic light
enum TrafficLightState {
  RED,
  RED_YELLOW,
  GREEN,
  YELLOW
};

TrafficLightState currentState = RED;

void setup() {
  // Initialize the LED pins as outputs
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  
  // Initialize the push button pin as an input with pull-up resistor
  pinMode(buttonPin, INPUT_PULLUP);
  
  // Initial state: Red light is ON
  digitalWrite(redPin, HIGH);
}

void loop() {
  // Check if the button is pressed
  if (digitalRead(buttonPin) == LOW) {
    // Change the traffic light state
    changeTrafficLightState();
    delay(1000);  // Debounce delay
  }
  
  // Update the traffic light based on the current state
  updateTrafficLight();
}

void changeTrafficLightState() {
  switch (currentState) {
    case RED:
      currentState = GREEN;
      break;
    case GREEN:
      currentState = YELLOW;
      break;
    case YELLOW:
      currentState = RED;
      break;
    default:
      break;
  }
}

void updateTrafficLight() {
  // Turn off all LEDs
  digitalWrite(redPin, LOW);
  digitalWrite(yellowPin, LOW);
  digitalWrite(greenPin, LOW);
  
  // Update LEDs based on the current state
  switch (currentState) {
    case RED:
      digitalWrite(redPin, HIGH);
      break;
    case GREEN:
      digitalWrite(greenPin, HIGH);
      break;
    case YELLOW:
      digitalWrite(yellowPin, HIGH);
      break;
    default:
      break;
  }
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r