12 is not less than 10, so first if is false. 12 is less than 15, so second condition is true.
Step 2: Determine light value
Since timer < 15 is true, light is set to 'GREEN'.
Final Answer:
'GREEN' -> Option C
Quick Check:
timer=12 <15 -> light='GREEN' [OK]
Hint: Check conditions in order, timer 12 fits second condition [OK]
Common Mistakes:
Choosing 'RED' because timer is close to 10
Choosing 'YELLOW' by ignoring conditions order
Thinking code causes error
4. This PLC code snippet is intended to cycle traffic lights but does not work correctly:
state = 'RED'
if state == 'RED':
state = 'GREEN'
elif state == 'GREEN':
state = 'YELLOW'
elif state == 'YELLOW':
state = 'RED'
What is the main problem?
medium
A. The state variable is misspelled
B. The state changes only once because conditions are checked once
C. The code uses wrong comparison operators
D. The code lacks a timer to delay state changes
Solution
Step 1: Analyze state change logic
The code changes state immediately but only once; no loop or repeated check.
Step 2: Identify missing repeated execution
Without looping or timer, state changes once and stops, so no cycling happens.
Final Answer:
The state changes only once because conditions are checked once -> Option B
Quick Check:
Single run code = no cycling [OK]
Hint: State must update repeatedly, not just once [OK]
Common Mistakes:
Thinking variable name is wrong
Believing comparison operators are incorrect
Ignoring need for timing or looping
5. You want to create a PLC program that cycles traffic lights with these timings: red for 10 seconds, green for 15 seconds, yellow for 3 seconds. Which approach best implements this sequence?
hard
A. Use separate timers for each light but no state variable
B. Use a single timer that counts total time without resetting
C. Use random delays between light changes
D. Use a state machine with a timer that resets after each state duration
Solution
Step 1: Understand timing requirements
Each light needs a specific duration before switching to the next.
Step 2: Choose best control method
A state machine with a timer that resets after each state's time allows precise control and cycling.
Final Answer:
Use a state machine with a timer that resets after each state duration -> Option D
Quick Check:
State machine + timer reset = correct timing control [OK]
Hint: Reset timer each state for exact light durations [OK]
Common Mistakes:
Using one timer without reset causes wrong timing
Random delays break predictable sequence
No state variable causes confusion in sequence
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.