+—————————+ | | | Traffic Light | | | +—————————+
|
| +----------------------------------+
| | |
+-->| Define traffic light phases and |
| their durations |
| |
+----------------------------------+
|
| +----------------------------------+
| | |
+-->| Define traffic flow ratios |
| |
+----------------------------------+
|
| +------------------------------+
+-->| Define initial phase and start|
| the timer |
+------------------------------+
|
| +--------------------+
+-->| Update remaining time|
| | for current phase |
| +--------------------+
|
| +--------------------+
| | Check if current |
+---| phase has ended |
| +--------------------+
|
| +---------------------+
| | Switch to next phase|
+---| when current phase |
| | has ended |
| +---------------------+
|
| +---------------------+
| | Print current phase |
+---| and remaining time |
| +---------------------+
|
| +--------------------+
+-->| Wait for one second |
| before checking |
| again |
+--------------------+