Bird
Raised Fist0
PLC Programmingscripting~10 mins

Indicator light control in PLC Programming - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Indicator light control
Start
↓
Read Input
↓
Is Input ON?
No→Turn Light OFF
Yes↓
Turn Light ON
↓
Loop Back to Start
The PLC reads an input signal, checks if it is ON, then turns the indicator light ON or OFF accordingly, repeating this cycle continuously.
Execution Sample
PLC Programming
IF Input = TRUE THEN
  Light := TRUE;
ELSE
  Light := FALSE;
END_IF;
This code turns the indicator light ON if the input is TRUE, otherwise turns it OFF.
Execution Table
StepInputCondition (Input=TRUE?)ActionLight State
1FALSEFALSETurn Light OFFOFF
2TRUETRUETurn Light ONON
3TRUETRUETurn Light ONON
4FALSEFALSETurn Light OFFOFF
5FALSEFALSETurn Light OFFOFF
6TRUETRUETurn Light ONON
💡 PLC runs continuously; this trace shows 6 cycles of input checking and light control.
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5After 6
InputFALSEFALSETRUETRUEFALSEFALSETRUE
LightOFFOFFONONOFFOFFON
Key Moments - 2 Insights
Why does the light turn OFF when the input is FALSE?
Because the condition Input=TRUE is FALSE (see execution_table steps 1, 4, 5), so the ELSE branch runs, turning the light OFF.
What happens if the input stays TRUE for multiple cycles?
The light stays ON continuously (see execution_table steps 2 and 3), because the condition remains TRUE and the ON action repeats.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table at step 4. What is the state of the light?
AON
BOFF
CUndefined
DFlashing
💡 Hint
Check the 'Light State' column at step 4 in the execution_table.
At which step does the input first become TRUE?
AStep 1
BStep 4
CStep 2
DStep 6
💡 Hint
Look at the 'Input' column in the execution_table to find when it changes from FALSE to TRUE.
If the input is always FALSE, what will the light state be after 3 cycles?
AOFF
BON
CFlashing
DAlternating
💡 Hint
Refer to the variable_tracker for 'Light' when 'Input' is FALSE repeatedly.
Concept Snapshot
Indicator Light Control in PLC:
- Read input signal
- If input TRUE, set light ON
- Else, set light OFF
- Repeat continuously
- Simple IF-ELSE logic controls light state
Full Transcript
This example shows how a PLC controls an indicator light based on an input signal. The PLC reads the input each cycle. If the input is TRUE, the light turns ON. If the input is FALSE, the light turns OFF. This check repeats continuously. The execution table traces six cycles showing input values, condition checks, actions taken, and resulting light states. The variable tracker shows how input and light states change over time. Key moments clarify why the light turns ON or OFF depending on input. The quiz tests understanding of light state at specific steps and behavior when input changes or stays constant.

Practice

(1/5)
1. What is the main purpose of an indicator light in a PLC-controlled machine?
easy
A. To increase the machine's speed
B. To show the status of the machine or process clearly
C. To store data from the machine
D. To control the temperature of the machine

Solution

  1. Step 1: Understand indicator light function

    Indicator lights are used to show if a machine is running, stopped, or has a fault.
  2. Step 2: Match purpose to options

    Only To show the status of the machine or process clearly describes showing status clearly, which is the main purpose.
  3. Final Answer:

    To show the status of the machine or process clearly -> Option B
  4. Quick Check:

    Indicator lights = show status [OK]
Hint: Indicator lights always show machine status visually [OK]
Common Mistakes:
  • Thinking indicator lights control machine speed
  • Confusing indicator lights with data storage
  • Assuming indicator lights control temperature
2. Which of the following is the correct syntax to turn ON an indicator light named Light1 when a condition StartButton is TRUE in a PLC program?
easy
A. IF StartButton THEN Light1 = ON;
B. IF (StartButton) Light1 = ON;
C. IF StartButton Light1 = ON;
D. IF StartButton THEN Light1 ON;

Solution

  1. Step 1: Identify correct IF syntax in PLC

    Standard PLC IF syntax uses 'IF condition THEN action;' format.
  2. Step 2: Check each option

    IF StartButton THEN Light1 = ON; matches correct syntax with 'IF StartButton THEN Light1 = ON;'. Others miss THEN or equal sign.
  3. Final Answer:

    IF StartButton THEN Light1 = ON; -> Option A
  4. Quick Check:

    IF ... THEN ... = ...; syntax [OK]
Hint: Always use THEN and = in PLC IF statements [OK]
Common Mistakes:
  • Omitting THEN keyword
  • Missing equal sign for assignment
  • Incorrect parentheses usage
3. Given this PLC code snippet:
IF Sensor = TRUE THEN
  LightGreen = ON;
ELSE
  LightGreen = OFF;
END_IF;

What will be the state of LightGreen if Sensor is FALSE?
medium
A. LightGreen will be ON
B. LightGreen will blink
C. LightGreen state will not change
D. LightGreen will be OFF

Solution

  1. Step 1: Analyze IF condition with Sensor FALSE

    Since Sensor = FALSE, the ELSE branch runs.
  2. Step 2: Determine LightGreen state in ELSE branch

    ELSE sets LightGreen = OFF, so light turns off.
  3. Final Answer:

    LightGreen will be OFF -> Option D
  4. Quick Check:

    Sensor FALSE -> ELSE -> LightGreen OFF [OK]
Hint: FALSE condition triggers ELSE branch [OK]
Common Mistakes:
  • Assuming light stays ON when sensor is FALSE
  • Thinking light blinks automatically
  • Ignoring ELSE branch
4. Identify the error in this PLC code controlling an indicator light:
IF Start = TRUE THEN
  LightRed = ON
ELSE
  LightRed = OFF;
END_IF;
medium
A. Wrong variable name 'Start'
B. Incorrect use of ELSE keyword
C. Missing semicolon after 'LightRed = ON'
D. Missing END_IF statement

Solution

  1. Step 1: Check statement endings

    PLC statements require semicolons at end; 'LightRed = ON' lacks semicolon.
  2. Step 2: Verify other syntax parts

    ELSE and END_IF are correctly used; variable name 'Start' is valid.
  3. Final Answer:

    Missing semicolon after 'LightRed = ON' -> Option C
  4. Quick Check:

    Every statement ends with ; [OK]
Hint: Check every statement ends with a semicolon [OK]
Common Mistakes:
  • Forgetting semicolons
  • Misusing ELSE keyword
  • Assuming END_IF is optional
5. You want to control two indicator lights: LightGreen turns ON when MachineRunning is TRUE, and LightRed turns ON when MachineFault is TRUE. Which PLC code correctly implements this logic?
hard
A. IF MachineRunning THEN LightGreen = ON; ELSE LightGreen = OFF; END_IF;\nIF MachineFault THEN LightRed = ON; ELSE LightRed = OFF; END_IF;
B. IF MachineRunning = TRUE AND MachineFault = FALSE THEN LightGreen = ON; ELSE LightGreen = OFF; END_IF;
C. IF MachineRunning THEN LightGreen = ON; IF MachineFault THEN LightRed = ON; END_IF;
D. IF MachineRunning OR MachineFault THEN LightGreen = ON; ELSE LightRed = ON; END_IF;

Solution

  1. Step 1: Understand requirements for each light

    LightGreen depends only on MachineRunning; LightRed depends only on MachineFault.
  2. Step 2: Check each option for correct separate control

    IF MachineRunning THEN LightGreen = ON; ELSE LightGreen = OFF; END_IF;\nIF MachineFault THEN LightRed = ON; ELSE LightRed = OFF; END_IF; uses two separate IF blocks, correctly controlling each light independently.
  3. Step 3: Identify errors in other options

    IF MachineRunning = TRUE AND MachineFault = FALSE THEN LightGreen = ON; ELSE LightGreen = OFF; END_IF; combines conditions incorrectly; IF MachineRunning THEN LightGreen = ON; IF MachineFault THEN LightRed = ON; END_IF; misses ELSE for LightRed OFF; IF MachineRunning OR MachineFault THEN LightGreen = ON; ELSE LightRed = ON; END_IF; mixes logic wrongly.
  4. Final Answer:

    Separate IF blocks for each light with proper ON/OFF control -> Option A
  5. Quick Check:

    Separate IFs for independent lights [OK]
Hint: Control each light with its own IF-ELSE block [OK]
Common Mistakes:
  • Combining conditions incorrectly
  • Missing ELSE to turn lights OFF
  • Using OR instead of separate controls
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard