oolean;
begin
d: = true;
d: = d and (INIT = (INIT and Lpt. ReadPort (GetCurrentPort, 2)));
Pin16: = d;
end;
function TForm1. Pin17: boolean;
var
d: boolean;
begin
d: = true;
d: = d xor (SELECTIN = (SELECTIN and Lpt. ReadPort (GetCurrentPort, 2)));
Pin17: = d;
end;
function TForm1. Pin10: boolean;
var
d: boolean;
begin
d: = true;
d: = d and (ACK = (ACK and Lpt. ReadPort (GetCurrentPort, 1)));
Pin10: = d;
end;
function TForm1. Pin11: boolean;
var
d: boolean;
begin
d: = true;
d: = d xor (BUSY = (BUSY and Lpt. ReadPort (GetCurrentPort, 1)));
Pin11: = d;
end;
function TForm1. Pin12: boolean;
var
d: boolean;
begin
d: = true;
d: = d and (PAPEREND = (PAPEREND and Lpt. ReadPort (GetCurrentPort, 1)));
Pin12: = d;
end;
function TForm1. Pin13: boolean;
var
d: boolean;
begin
d: = true;
d: = d and (SELECT = (SELECT and Lpt. ReadPort (GetCurrentPort, 1)));
Pin13: = d;
end;
function TForm1. Pin15: boolean;
var
d: boolean;
begin
d: = true;
d: = d and (ERROR = (ERROR and Lpt. ReadPort (GetCurrentPort, 1)));
Pin15: = d;
end; end.
Додаток 2
Код програми написаний на мові Delphi для виводу двійкового числа 10000000 на світлодіодні Індикатори лабораторного макету Із періодом Зміни ІНФОРМАЦІЇ в 1 секунду.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, LPTIO, ExtCtrls, StdCtrls, Spin;
type
TForm1 = class (TForm)
Button1: TButton;
Timer1: TTimer;
SpinEdit1: TSpinEdit;
CheckBox1: TCheckBox;
Label1: TLabel;
Label2: TLabel;
procedure FormCreate (Sender: TObject);
procedure FormDestroy (Sender: TObject);
procedure Timer1Timer (Sender: TObject);
procedure Button1Click (Sender: TObject);
procedure SpinEdit1Change (Sender: TObject);
private
{Private declarations}
Lpt: TLptPortConnection;
public
{Public declarations}
function GetCurrentPort: byte;
end;
var
Form1: TForm1;
implementation
{$ R *. dfm}
procedure TForm1. FormCreate (Sender: TObject);
var
msg: AnsiString;
begin
Lpt: = TLptPortConnection. Create;
if not Lpt. Ready then
begin {об'єкт не готовий - покажемо код помилки}
msg: = 'Помилка при створенні об'єкта Lpt, драйвер ERROR, код = '+ IntToStr (GetLastError ());
Application. MessageBox (PChar (msg), 'ERROR', MB_OK);
Application. Terminate;
end;
Lpt. WritePort (GetCurrentPort, 0,0);
Lpt. WritePort (GetCurrentPort, 2,3);
end;
procedure TForm1. FormDestroy (Sender: TObject);
begin
Lpt. Destroy;
Timer1. Enabled: = false;
end;
function TForm1. GetCurrentPort: byte;
begin
if Lpt. IsPortPresent (LPT1) then
GetCurrentPort: = LPT1
else
if Lpt. IsPortPresent (LPT2) then
GetCurrentPort: = LPT2
else
if Lpt. IsPortPresent (LPT3) then
GetCurrentPort: = LPT3;
end;
procedure TForm1. Timer1Timer (Sender: TObject);
begin
Lpt. WritePort (GetCurrentPort, 0, (1 xor Lpt. ReadPort ((GetCurrentPort), 0)));
if CheckBox1. Checked = false then
CheckBox1. Checked: = true
else
CheckBox1. Checked: = false;
end;
procedure TForm1. Button1Click (Sender: TObject);
begin
if Timer1. Enabled = false then
begin
Timer1. Enabled: = true;
Button1. Caption: = 'Stop';
end
else
begin
Timer1. Enabled: = false;
Button1. Caption: = 'Start';
end;
end;
procedure TForm1. SpinEdit1Change (Sender: TObject);
begin
Timer1. Interval: = SpinEdit1. Value;
end;
end.
В