PROGRAM Main_PRG
VAR                   
        iMotor: ARRAY[1..10] OF INT := [15,30,29,27,23];
    iOutPut : INT;
    iMotorCmd : INT := 1;
    iMotorSts : INT;
    bStartBtn: BOOL;
    bStopBtn: BOOL;
    RT: ARRAY[1..5] OF R_TRIG;
END_VAR
RT[1](CLK := bStopBtn);
RT[2](CLK := bStartBtn);
IF RT[1].Q THEN
    IF iMotorCmd <5 THEN
        iMotorCmd := iMotorCmd + 1;
    ELSE
        iMotorCmd := 1;            
    END_IF
    iOutPut := 0;
END_IF
IF RT[2].Q THEN
    IF iMotorCmd >= 1 AND iMotorCmd <= 5 THEN    
        iOutPut := iMotor[iMotorCmd];
        iMotorSts := iMotorCmd;
    ELSE
        iMotorSts := 0;    
        iOutPut := 0;
    END_IF
END_IF