I am working on a traffic light control system for an intersection with a **main road (Vp)** and a **secondary road (Vs)**, using:
- **Vehicle detectors**:
- **Dp** (main road).
- **Ds** (secondary road).
- **Pedestrian buttons**:
- **Pp** (to cross the main road).
- **Ps** (to cross the secondary road).
Which can be expresed with the following diagram:

- **Non-retriggerable monostable timers**:
- **5 seconds** (I₅, output T₅).
- **15 seconds** (I₁₅, output T₁₅).

### **Specifications:**
1. **Main road (Vp):**
- **Green (Vp)** must stay on for **at least 30 seconds**, but can be extended if:
- A vehicle is detected on the secondary road (Ds triggered).
- A pedestrian presses **Pp**.
- Then, **Yellow (Ap)** for **5 seconds** (using T₅).
- During Vp and Ap, the secondary road must be **Red (Rs)**.
2. **Secondary road (Vs):**
- **Green (Vs)** must stay on for **at least 15 seconds**, but can be extended if:
- A vehicle is detected on the main road (Dp triggered).
- A pedestrian presses **Ps**.
- Then, **Yellow (As)** for **5 seconds** (using T₅).
- During Vs and As, the main road must be **Red (Rp)**.
3. The cycle repeats indefinitely.
### **Implementation Questions:**
1. **How many states should the finite state machine (FSM) have?**
- Considering **Vp (green) → Ap (yellow) → Vs (green) → As (yellow) → (cycle)**, would **4 base states** be sufficient?
- Or should I add more states to handle **extensions due to detectors (Dp/Ds) or pedestrians (Pp/Ps)**?
2. **How should state transitions be handled?**
- For example, how to prioritize a pedestrian signal (**Pp/Ps**) over the minimum green time?
- Should I use **combined conditions** (e.g., "Pp OR Ds") to exit the **Vp state** before 30s?
3. **How to generate the 30-second delay if I only have 5s and 15s timers? **
- No diagrams needed—just a brief textual explanation of the FSM structure.
- Prefer avoiding microcontrollers (only basic FSM and timers).
- **Vehicle detectors**:
- **Dp** (main road).
- **Ds** (secondary road).
- **Pedestrian buttons**:
- **Pp** (to cross the main road).
- **Ps** (to cross the secondary road).
Which can be expresed with the following diagram:

- **Non-retriggerable monostable timers**:
- **5 seconds** (I₅, output T₅).
- **15 seconds** (I₁₅, output T₁₅).

### **Specifications:**
1. **Main road (Vp):**
- **Green (Vp)** must stay on for **at least 30 seconds**, but can be extended if:
- A vehicle is detected on the secondary road (Ds triggered).
- A pedestrian presses **Pp**.
- Then, **Yellow (Ap)** for **5 seconds** (using T₅).
- During Vp and Ap, the secondary road must be **Red (Rs)**.
2. **Secondary road (Vs):**
- **Green (Vs)** must stay on for **at least 15 seconds**, but can be extended if:
- A vehicle is detected on the main road (Dp triggered).
- A pedestrian presses **Ps**.
- Then, **Yellow (As)** for **5 seconds** (using T₅).
- During Vs and As, the main road must be **Red (Rp)**.
3. The cycle repeats indefinitely.
### **Implementation Questions:**
1. **How many states should the finite state machine (FSM) have?**
- Considering **Vp (green) → Ap (yellow) → Vs (green) → As (yellow) → (cycle)**, would **4 base states** be sufficient?
- Or should I add more states to handle **extensions due to detectors (Dp/Ds) or pedestrians (Pp/Ps)**?
2. **How should state transitions be handled?**
- For example, how to prioritize a pedestrian signal (**Pp/Ps**) over the minimum green time?
- Should I use **combined conditions** (e.g., "Pp OR Ds") to exit the **Vp state** before 30s?
3. **How to generate the 30-second delay if I only have 5s and 15s timers? **
- No diagrams needed—just a brief textual explanation of the FSM structure.
- Prefer avoiding microcontrollers (only basic FSM and timers).