# Traffic light FSM

Thread Starter

#### massawa

Joined Apr 20, 2022
4
Hello,

I need help with a traffic light FSM problem. We need to design a traffic light controller FSM which spends 1 sec in each state.
The clock frequency in this example is 1 Hz, and my circuit works as expected.

Then we need to modify to circuit to spend 4 s in the red, 1 sec in the red-yellow, 2 sec in the green and 1 sec in the yellow state. But I have no idea how to do that. Can you help me with this? Thank you.

#### eetech00

Joined Jun 8, 2013
4,042
Hint: Setup sequencial timers, each triggered by the previous state

#### dl324

Joined Mar 30, 2015
17,122
Welcome to AAC!
Then we need to modify to circuit to spend 4 s in the red, 1 sec in the red-yellow, 2 sec in the green and 1 sec in the yellow state. But I have no idea how to do that.
Show us the steps you took to do the initial design. Why did you use inverters when the flip flops already had complementary outputs?

Thread Starter

#### massawa

Joined Apr 20, 2022
4
Welcome to AAC!

Show us the steps you took to do the initial design. Why did you use inverters when the flip flops already had complementary outputs?
Thank you!
Yes, you are right, inverters are not necessary. I modified the circuit according this.
These are the steps I took. I hope it is understandable.

#### dl324

Joined Mar 30, 2015
17,122
I hope it is understandable.
Not very.

I think you're going to have to use a more formal method for more than 4 states.

What does the RY light indicate? A traffic light has 6 different lights. Are you only representing lights from one direction?

Thread Starter

#### massawa

Joined Apr 20, 2022
4
Not very.

I think you're going to have to use a more formal method for more than 4 states.

What does the RY light indicate? A traffic light has 6 different lights. Are you only representing lights from one direction?
Well, okay, I think the misunderstanding is caused by the difference between our countries.
So in my country traffic lights have 4 states (excluding flashing): red, red+yellow (at the same time), green, yellow.
And yes, I am representing lights from one direction only.

#### dl324

Joined Mar 30, 2015
17,122
So in my country traffic lights have 4 states (excluding flashing): red, red+yellow (at the same time), green, yellow.
And yes, I am representing lights from one direction only.
Do you know how to extend the method you used to work for 8 states?

I assume the red+yellow is to warn drivers that the light is about to turn green. Why would you need something like that?

#### crutschow

Joined Mar 14, 2008
34,836
You can also use a parallel-out shift-register to do timing.

#### Ian0

Joined Aug 7, 2020
10,269
You could also have a counter with 8 states (CD4017 for example), and use the "OR" of the first 4 states = red, state 5= red/amber, state 6 OR state 7 = green, state 8 = amber.

#### Ian0

Joined Aug 7, 2020
10,269
I assume the red+yellow is to warn drivers that the light is about to turn green. Why would you need something like that?
So that they can put the vehicle in gear and get their left foot ready on the clutch pedal.
(If they only have 2 seconds on green they need a speedy getaway!)

Similar threads