SC PASCAL: CREATING A TIMER

We are going to write a script that keeps a led on during some time after pressing a button.

We are going to use the parking brake lever, connected to input number 6, and its led connected to output nu,ber 5.

The code is this one:


PROGRAM Timer;

var
Main1:string;

procedure OnInputChange(sn:string;input,value:byte);
begin
if (sn=Main1) then begin
if ((input=6) and (value=1)) then begin
SetTimer(1, true);
WriteOut(main1,5,1);
end;
end;
end;

procedure OnTimer1();
begin
WriteOut(Main1, 5,0);
SetTimer(1, false);
end;

//MAIN
Begin
Main1:='SIMIO000228';
CreateTimer(1, 10000);
End.

You can find further info in this video:

 


Last edition: 10.04.2020

 

Versión española

English version