Introduction
Indicator light control helps show the status of machines or processes clearly and quickly.
IF condition THEN
indicator_light := TRUE;
ELSE
indicator_light := FALSE;
END_IF;IF machine_running THEN
green_light := TRUE;
ELSE
green_light := FALSE;
END_IF;IF error_detected THEN
red_light := TRUE;
ELSE
red_light := FALSE;
END_IF;IF task_complete THEN
yellow_light := TRUE;
ELSE
yellow_light := FALSE;
END_IF;PROGRAM IndicatorLightControl
VAR
machine_running : BOOL := TRUE;
error_detected : BOOL := FALSE;
green_light : BOOL := FALSE;
red_light : BOOL := FALSE;
END_VAR
IF machine_running THEN
green_light := TRUE;
ELSE
green_light := FALSE;
END_IF;
IF error_detected THEN
red_light := TRUE;
ELSE
red_light := FALSE;
END_IF;
// Output status
IF green_light THEN
// Turn on green indicator
;
END_IF;
IF red_light THEN
// Turn on red indicator
;
END_IF;
// For demonstration, print status
PRINT('Green Light: ' + TO_STRING(green_light));
PRINT('Red Light: ' + TO_STRING(red_light));
END_PROGRAMLight1 when a condition StartButton is TRUE in a PLC program?IF Sensor = TRUE THEN LightGreen = ON; ELSE LightGreen = OFF; END_IF;
LightGreen if Sensor is FALSE?IF Start = TRUE THEN LightRed = ON ELSE LightRed = OFF; END_IF;
LightGreen turns ON when MachineRunning is TRUE, and LightRed turns ON when MachineFault is TRUE. Which PLC code correctly implements this logic?Pass the test and this pattern moves unknown