How rubengameztorrijos/semaforo_pulsador_peatonal_y_vehiculos works
Main Components
• Hardware Interface:
• LEDs for Vehicles – Connected to Port B, bit 0.
• LEDs for Pedestrians – Connected to Port D, bits 2 and 3.
• Pedestrian Button – Connected to Port D, pin 6.
• Microcontroller:
• ATmega328P (as mentioned in the README for Wokwi and Arduino use).
• This is where the control logic (state machine) runs.
• Software/Firmware:
• Assembly Code Module (main.S): Represents low-level control logic.
• Arduino Sketch (sketch.ino): Provides an alternative implementation to run on an Arduino Uno.
• Development/Simulation Environment:
File Structure for Architectural Clues
• The top-level files (LICENSE, README.md) are standard, ensuring clarity.
• This dual implementation implies a layered design in the firmware that could be abstracted as a central control unit with hardware abstraction layers for interface.
a. Hardware Layer:
• External hardware components:
• Vehicle LED (Port B, bit 0)
• Pedestrian LEDs (Port D, bits 2 and 3)
• Pedestrian Button (Port D, pin 6)
b. Microcontroller/Control Unit:
• Center the ATmega328P as the core processing unit.
• State Machine Controller – manages the traffic light cycle based on the current state (five phases) and responds to the pedestrian button interrupt by switching to the priority phase.
• Interrupt/Signal Processor – handle the immediate transition upon button press.
c. Software/Firmware Modules:
• Assembly Module (main.S): Indicate that this module provides low-level control.
• Arduino Module (sketch.ino): Represents a higher-level, possibly more accessible implementation.
• Modules to show that they feed the same control logic into the microcontroller’s operation.
d. Simulation Environment:
Relationships/Interactions
• From the Pedestrian Button (input) to the Interrupt/Signal Processor in the Microcontroller.
• From the Microcontroller’s State Machine Controller to the LED outputs.
• This highlights the dependency on the external hardware signals and the response-by-control logic.
Architectural Patterns & Design Principles
• State machine pattern controlling the semáforo cycles.
• Separation of concerns:
• Hardware abstraction (interaction with ports and pins).
• Control logic (state transitions based on inputs).
• Simulation vs. deployment implementations (Assembly vs. Arduino code).