Tampilan Form
unit PPDHn;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Timer1: TTimer;
Timer2: TTimer;
Timer3: TTimer;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape8: TShape;
procedure Button8Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
procedure urutanLampu(lampuke : Byte);
public
{ Public declarations }
end;
var
Form1: TForm1; i:integer;
implementation
{$R *.dfm}
procedure PortOut(Port : Word; Data : Byte); stdcall; external 'io.dll';
function PortIn(Port:Word):Byte; stdcall; external 'io.dll';
procedure delay(lama:longint);
var ref:longint;
begin
ref:=gettickcount;
repeat application.processmessages;
until ((gettickcount-ref)>=lama);
end;
procedure TForm1.urutanLampu(lampuke : Byte);
begin
if lampuke = 0 then
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clWhite;
end else
if lampuke = 1 then
begin
shape1.Brush.Color := clGreen;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clWhite;
end else
if lampuke = 2 then
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clGreen;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clWhite;
end else
if lampuke = 4 then
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clGreen;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clWhite;
end else
if lampuke = 8 then
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clGreen;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clWhite;
end else
if lampuke = 16 then
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clGreen;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clWhite;
end else
if lampuke = 32 then
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clGreen;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clWhite;
end else
if lampuke = 64then
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clGreen;
shape8.Brush.Color := clWhite;
end else
if lampuke = 128 then
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clGreen;
END ELSE
if lampuke = 255 then
begin
shape1.Brush.Color := clGreen;
shape2.Brush.Color := clGreen;
shape3.Brush.Color := clGreen;
shape4.Brush.Color := clGreen;
shape5.Brush.Color := clGreen;
shape6.Brush.Color := clGreen;
shape7.Brush.Color := clGreen;
shape8.Brush.Color := clGreen;
END;
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
Portout (888,128);
urutanLampu (128);
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Portout (888,64);
urutanLampu (64);
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
Portout (888,32);
urutanLampu (32);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Portout (888,16);
urutanLampu (16);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Portout (888,8);
urutanLampu (8);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Portout (888,4);
urutanLampu (4);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Portout (888,2);
urutanLampu (2);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Portout (888,1);
urutanLampu (1);
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
if button9.Caption = 'Go' then
begin
Button9.Caption := 'Out';
timer1.Enabled:= true;
end else
begin
Button9.Caption := 'Go';
timer1.Enabled:= false;
Portout (888,0);
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clWhite;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if shape1.Brush.Color = clred then
begin
shape1.Brush.Color := clGreen;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clGreen;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clGreen;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clGreen;
shape8.Brush.Color := clWhite;
portout(888,85);
delay(1000);
end else
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clGreen;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clGreen;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clGreen;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clGreen;
portout(888,170);
delay(1000);
end;
end;
procedure TForm1.Button14Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button12Click(Sender: TObject);
begin
PortOut(888, 255);
urutanLampu(255);
end;
procedure TForm1.Button13Click(Sender: TObject);
begin
PortOut(888, 0);
urutanLampu(0);
end;
procedure TForm1.Button11Click(Sender: TObject);
begin
if button11.Caption = 'Go' then
begin
Button11.Caption := 'Out';
timer3.Enabled:= true;
end else
begin
Button11.Caption := 'Go';
timer3.Enabled:= false;
Portout (888,0);
shape1.Brush.Color := clGreen;
shape2.Brush.Color := clGreen;
shape3.Brush.Color := clGreen;
shape4.Brush.Color := clGreen;
shape5.Brush.Color := clGreen;
shape6.Brush.Color := clGreen;
shape7.Brush.Color := clGreen;
shape8.Brush.Color := clGreen;
end;
end;
procedure TForm1.Timer3Timer(Sender: TObject);
begin
if shape1.Brush.Color = clred then
begin
shape1.Brush.Color := clGreen;
shape2.Brush.Color := clGreen;
shape3.Brush.Color := clwhite;
shape4.Brush.Color := clwhite;
shape5.Brush.Color := clGreen;
shape6.Brush.Color := clGreen;
shape7.Brush.Color := clwhite;
shape8.Brush.Color := clWhite;
portout(888,51);
delay(100);
end else
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clwhite;
shape4.Brush.Color := clwhite;
shape5.Brush.Color := clGreen;
shape6.Brush.Color := clGreen;
shape7.Brush.Color := clGreen;
shape8.Brush.Color := clGreen;
portout(888,240);
delay(100);
begin
shape1.Brush.Color := clGreen;
shape2.Brush.Color := clGreen;
shape3.Brush.Color := clGreen;
shape4.Brush.Color := clGreen;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clwhite;
shape7.Brush.Color := clwhite;
shape8.Brush.Color := clWhite;
portout(888,15);
delay(100);
begin
shape1.Brush.Color := clwhite;
shape2.Brush.Color := clwhite;
shape3.Brush.Color := clwhite;
shape4.Brush.Color := clwhite;
shape5.Brush.Color := clwhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clwhite;
portout(888,0);
delay(100) ;
end;
end;
end;
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
if button10.Caption = 'Go' then
begin
Button10.Caption := 'Out';
timer2.Enabled:= true;
end else
begin
Button10.Caption := 'Go';
timer2.Enabled:= false;
Portout (888,0);
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clWhite;
end;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
if shape1.Brush.Color = clred then
begin
shape1.Brush.Color := clwhite;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clGreen;
shape5.Brush.Color := clGreen;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clwhite;
portout(888,24);
delay(100);
end else
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clwhite;
shape3.Brush.Color := clGreen;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clGreen;
shape7.Brush.Color := clwhite;
shape8.Brush.Color := clWhite;
portout(888,36);
delay(100);
begin
shape1.Brush.Color := clWhite;
shape2.Brush.Color := clGreen;
shape3.Brush.Color := clwhite;
shape4.Brush.Color := clWhite;
shape5.Brush.Color := clWhite;
shape6.Brush.Color := clwhite;
shape7.Brush.Color := clGreen;
shape8.Brush.Color := clWhite;
portout(888,66);
delay(100);
begin
shape1.Brush.Color := clGreen;
shape2.Brush.Color := clWhite;
shape3.Brush.Color := clWhite;
shape4.Brush.Color := clwhite;
shape5.Brush.Color := clwhite;
shape6.Brush.Color := clWhite;
shape7.Brush.Color := clWhite;
shape8.Brush.Color := clGreen;
portout(888,129);
delay(100) ;
begin
shape1.Brush.Color := clGreen;
shape2.Brush.Color := clGreen;
shape3.Brush.Color := clGreen;
shape4.Brush.Color := clGreen;
shape5.Brush.Color := clGreen;
shape6.Brush.Color := clGreen;
shape7.Brush.Color := clGreen;
shape8.Brush.Color := clGreen;
portout(888,255);
delay(100) ;
end;
end;
end;
end;
end;
end.