{ ------------------------------------------------------------------------- }
Program putar_motor_stepper;
Uses crt;
Const i : array [1..8] of byte = (1,3,2,6,4,12,8,9);
Var j,k,x,y : integer;
c : char;
Procedure putar_kanan;
Begin
If j > 7 Then j := 1 else inc ( j );
Port [$378] := i ( j );
End;
Procedure putar_kiri;
Begin
If j < 2 Then j := 8 else dec ( j );
Port [$378] := i ( j );
End;
Begin
Port [$37A] := $40; { 0100 0000 : enable bi-di }
k := Port [$378]; { baca posisi awal motor }
Port [$37A] := $00; { 0000 0000 : disable bi-di }
j := 1;
Repeat
If k <> i ( j ) Then inc ( j );
Until ( k = i ( j ) or ( j > 8 );
If j > 8 Then Begin
Write ('Ada kesalahan!'); Exit;
End;
Write ('Putar k[a ]nan, ki[r]i,e[x]it ?'];
x := wherex; y := wherey;
Repeat
Gotoxy ( x, y ); c := Readkey; Write ( c );
c := Upcase ( c );
Case c Of
'A' : putar_kanan;
'R' : putar_kiri;
End;
Until c = 'X';
End.
{ ------------------------------------------------------------------------- }
Tidak ada komentar:
Posting Komentar