/*
Wokwi | questions
Hello. I've been using wokwi for a few months now. Has anyone encountered this error?
chicago33 — 12:25 AM Monday, December 8, 2025
Project Link: https://wokwi.com/projects/449363419244376065?gh=1
*/
// === Jose Camacho ====
// Module #5 project
//North South LEDs pin configuration
const int red_LED1 = 14; // The red LED1 is wired to ESP32 board pin GPIO14
const int yellow_LED1 = 12; // The yellow LED1 is wired to ESP32 board pin GPIO12
const int green_LED1 = 13; // The green LED1 is wired to ESP32 board pin GPIO13
//East West LEDs pin configuration
const int red_LED2 = 25; // The red LED2 is wired to Mega board pin GPIO25
const int yellow_LED2 = 26; // The yellow LED2 is wired to Mega board pin GPIO 26
const int green_LED2 = 27; // The green LED2 is wired to Mega board pin GPIO 27
//setup crosswalk value and button variables
const int Xw_button = 33; //Cross Walk button
bool Xw_value = false;
//Define what happens when interrupt is activated
void ARDUINO_ISR_ATTR crosswalkB()
//void IRAM_ATTR crosswalkB()
{ // Cross Walk button interrupt handler
Xw_value = true;
}
// the setup function runs once when you press reset or power the board
void setup()
{
//setup crosswalk button as input and attach the Interrupt
pinMode(Xw_button, INPUT_PULLUP); // 0=pressed, 1 = unpressed button
attachInterrupt(Xw_button, crosswalkB, RISING);
//setup serial speed
Serial.begin(115200);
// NS pin direction set to output
pinMode(red_LED1, OUTPUT); // initialize digital pin 14 (Red LED1) as an output.
pinMode(yellow_LED1, OUTPUT); // initialize digital pin 12 (yellow LED1) as an output.
pinMode(green_LED1, OUTPUT); // initialize digital pin 13 (green LED1) as an output.
//EW pin direction set to output
pinMode(red_LED2, OUTPUT); // initialize digital pin 25(Red LED2) as an output.
pinMode(yellow_LED2, OUTPUT); // initialize digital pin 26 (yellow LED2) as an output.
pinMode(green_LED2, OUTPUT); // initialize digital pin 27 (green LED2) as an output.
// test
digitalWrite(red_LED1, HIGH);
digitalWrite(yellow_LED1, HIGH);
digitalWrite(green_LED1, HIGH);
digitalWrite(red_LED2, HIGH);
digitalWrite(yellow_LED2, HIGH);
digitalWrite(green_LED2, HIGH);
delay(1000);
digitalWrite(red_LED1, LOW);
digitalWrite(yellow_LED1, LOW);
digitalWrite(green_LED1, LOW);
digitalWrite(red_LED2, LOW);
digitalWrite(yellow_LED2, LOW);
digitalWrite(green_LED2, LOW);
}// end of setup
void loop() {
if (Xw_value == true) {
Serial.println("Button pressed");
Xw_value = false;
//delay(500);
}
}
North/South
East/West
Crosswalk