+VCC
RANGKAIAN KONTROL PARKIR 3
ANNISA DM 5/51-01 01
A
1 1
Wednesday , January 05, 2000 Title
Size Document Number Rev
Date: Sheet of
1' 2' 3' 4' 5' 6' 7' 8' 9' R_ARRAY 10K
2 3 4 5
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, DB, ADODB, Grids, DBGrids, StdCtrls, ExtCtrls, Buttons, DBCtrls, jpeg, ComCtrls, Printers;
type
TForm1 = class(TForm) MainMenu1: TMainMenu; ADOConnection1:
TADOConnection;
ADOTable1: TADOTable; Main1: TMenuItem; About1: TMenuItem; Database1: TMenuItem; Quit1: TMenuItem; Quit2: TMenuItem;
DataSource1: TDataSource; ADOTable2: TADOTable; DataSource2: TDataSource; DBGrid1: TDBGrid; MainData1: TMenuItem; MainMenu2: TMenuItem; datetext: TLabel;
StaticText1: TStaticText; StaticText2: TStaticText; StaticText3: TStaticText; StaticText4: TStaticText; Bevel1: TBevel;
StaticText5: TStaticText; StaticText6: TStaticText; DBText1: TDBText; DBText2: TDBText; Label3: TLabel; Label4: TLabel; Bevel2: TBevel; Bevel3: TBevel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Shape1: TShape; Shape2: TShape; Timer1: TTimer;
jamtext: TLabel; Image1: TImage; Timer2: TTimer; Edit1: TEdit; Edit2: TEdit; Button2: TButton;
ADOTable3: TADOTable; DataSource3: TDataSource; PrintDialog1: TPrintDialog; PrinterSetupDialog1: TPrinterSetupDialog; StatusBar1: TStatusBar; ADOTable2no: TAutoIncField; ADOTable2pin: TWideStringField; ADOTable2pass: TWideStringField; ADOTable2nama: TWideStringField; ADOTable2timein: TWideStringField; ADOTable2timeout: TWideStringField; ADOTable2Biaya: TWideStringField; ADOTable2Bulanan: TWideStringField; ADOTable2status: TWideStringField; B1: TMenuItem;
Label1: TLabel; Timer3: TTimer;
procedure About1Click(Sender: TObject);
procedure MainData1Click(Sender: TObject);
procedure Quit2Click(Sender: TObject); procedure MainMenu2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure B1Click(Sender: TObject); procedure Timer3Timer(Sender: TObject);
private public
end;
var
Form1: TForm1; cc, cd, bulan : string;
implementation
uses about, Unit2, Unit3; {$IFNDEF WIN32} const MAX_PATH = 44; {$ENDIF}
{$R *.dfm}
function Inp32(Alamat:word) :byte; stdcall; external 'inpout32.dll';
function
Out32(Alamat:word;Data:byte):byte; stdcall; external 'inpout32.dll';
procedure
TForm1.FormCreate(Sender: TObject);
begin
out32($378,255); cc :='he eh';
end;
procedure
TForm1.About1Click(Sender: TObject);
begin
AboutBox.show; end;
// Form database procedure
TForm1.MainData1Click(Sender: TObject);
begin form1.hide; form2.Show; end;
procedure
TForm1.Quit2Click(Sender: TObject);
begin Close; end;
procedure
TForm1.MainMenu2Click(Sender: TObject);
begin form1.Show; form2.hide; end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
Present: TDateTime; bulan: string;
Year, Month, Day,jam, menit, detik, ms: Word;
begin
Present := Now;
DecodeDate(Present, Year, Month, Day); if IntToStr(Month) = '1' then bulan := 'Januari';
if IntToStr(Month) = '2' then bulan := 'Februari';
if IntToStr(Month) = '3' then bulan := 'Maret';
if IntToStr(Month) = '4'then bulan := 'April';
if IntToStr(Month) = '5' then bulan := 'Mei';
if IntToStr(Month) = '6' then bulan := 'Juni';
if IntToStr(Month) = '7' then bulan := 'Juli';
if IntToStr(Month) = '8' then bulan := 'Agustus';
if IntToStr(Month) = '9' then bulan := 'September';
if IntToStr(Month) = '10' then bulan := 'Oktober';
if IntToStr(Month) = '11' then bulan := 'Nopember';
if IntToStr(Month) = '12' then bulan := 'Desember';
datetext.Caption := IntToStr(Day) + ' ' + bulan +' '+ IntToStr(Year);
DecodeTime(Time, jam, menit, detik, ms); jamtext.Caption := IntToStr (jam) + ':' + IntToStr (menit) + ':' +
end;
procedure
TForm1.Timer2Timer(Sender: TObject);
var
t1,t2,c1:string; begin
if(inp32($379))=127 then begin
label3.Caption := ' Pintu Masuk';
out32($378,255); end;
if(inp32($379))=143 then begin
t1:='0'; out32($378,255); end;
if(inp32($379))=207 then begin
t1:='1';
out32($378,255); end;
if(inp32($379))=15 then begin
t1:='2';
out32($378,255); end;
if(inp32($379))=79 then begin
t1:='3';
out32($378,255); end;
if(inp32($379))=175 then begin
t1:='4';
out32($378,255); end;
if(inp32($379))=239 then begin
t1:='5';
out32($378,255); end;
if(inp32($379))=47 then begin
t1:='6';
out32($378,255);
end;
if(inp32($379))=111 then begin
t1:='7';
out32($378,255); end;
if(inp32($379))=159 then begin
t1:='8';
out32($378,255); end;
if(inp32($379))=223 then begin
t1:='9';
out32($378,255); end;
if(inp32($379))=63 then if(edit1.GetTextLen < 4) then edit1.Text := ''
else
edit2.Text := '';
if(inp32($379))=119 then begin
label3.Caption := ' Keluar'; out32($378,255);
end;
if(inp32($379))=135 then begin
t2:='0';
out32($378,255); end;
if(inp32($379))=199 then begin
t2:='1';
out32($378,255); end;
if(inp32($379))=7 then begin
t2:='2';
out32($378,255); end;
if(inp32($379))=71 then begin
t2:='3';
out32($378,255); end;
if(inp32($379))=167 then
begin t2:='4';
out32($378,255); end;
if(inp32($379))=231 then begin
t2:='5';
out32($378,255); end;
if(inp32($379))=39 then begin
t2:='6';
out32($378,255); end;
if(inp32($379))=103 then begin
t2:='7';
out32($378,255); end;
if(inp32($379))=151 then begin
t2:='8';
out32($378,255); end;
if(inp32($379))=215 then begin
t2:='9';
out32($378,255); end;
if(inp32($379))=55 then if(edit1.GetTextLen < 4) then edit1.Text := ''
else
edit2.Text := '';
{ Cek Pin dan Pass }
if edit1.GetTextLen = 4 then begin
if ADOTable1.Locate('pin', edit1.Text, []) then
begin
if edit2.GetTextLen = 4 then
begin if
ADOTable1.FieldByName('pass').As String = edit2.Text then
begin
label3.Caption := ' Password Benar';
out32($378,1); button1.click; { pintu masuk }
end else begin
label3.Caption := ' Password Salah';
out32($378,64); label3.Caption := ''; end;
end else begin
label3.Caption := ' Pin Benar'; out32($378,1);
end; end else begin
label3.Caption := ' Pin Salah'; out32($378,64);
label3.Caption := ''; end;
end; end;
procedure TForm1.Button2Click(Sender: TObject);
var
btime,ctime,pin1,waktu1,waktu2,nama1,bia ya1 : string;
hrgticket : integer;
ATime, hsltime: TDateTime; Present: TDateTime;
bulan: string;
Year, Month, Day: Word; begin
btime := '2:59:59'; ctime := '00:59:59'; hrgticket := 2000 ;
Present := Now;
if IntToStr(Month) = '2' then bulan := 'Februari';
if IntToStr(Month) = '3' then bulan := 'Maret';
if IntToStr(Month) = '4'then bulan := 'April';
if IntToStr(Month) = '5' then bulan := 'Mei';
if IntToStr(Month) = '6' then bulan := 'Juni';
if IntToStr(Month) = '7' then bulan := 'Juli';
if IntToStr(Month) = '8' then bulan := 'Agustus';
if IntToStr(Month) = '9' then bulan := 'September';
if IntToStr(Month) = '10' then bulan := 'Oktober';
if IntToStr(Month) = '11' then bulan := 'Nopember';
if IntToStr(Month) = '12' then bulan := 'Desember';
{ Database } out32($378,1);
if (not ADOTable3.Locate('pin', edit1.Text, [])) then
begin
form1.ADOTable3.Insert;
form1.ADOTable3.FieldByName('pi n').AsString :=
AdoTable1.Fields[1].AsString;
form1.ADOTable3.FieldByName('m asuk').AsString := timetostr(time);
form1.ADOTable3.FieldByName('ke luar').AsString := '00:00:00';
form1.ADOTable3.Refresh; end;
if (ADOTable3.Locate('pin', edit1.Text, [])) then
begin if
ADOTable3.FieldByName('keluar'). AsString = '00:00:00' then
begin
form1.Shape1.Brush.Color := clblue ; form1.Shape2.Brush.Color := clwhite ;
form1.ADOTable3.edit;
form1.ADOTable3.FieldByName('masuk'). AsString := timetostr(time);
form1.ADOTable3.FieldByName('keluar'). AsString := timetostr(time);
form1.ADOTable3.Refresh; end
else begin ATime :=
StrToTime(ADOTable3.FieldByName('mas uk').AsString); { penghitungan jumlah harga }
if time < atime then begin
hsltime := strtotime('23:59:59') - atime;
hsltime := hsltime + ( time - strtotime('00:00:00') );
end else
hsltime := time - atime;
while hsltime > strtotime(btime) do begin
hsltime := hsltime - strtotime(ctime); hrgticket := hrgticket + 1000; end;
form1.ADOTable3.Edit;
form1.ADOTable3.FieldByName('keluar'). AsString := timetostr(time);
form1.ADOTable3.Refresh;
form1.Shape2.Brush.Color := clblue ; form1.Shape1.Brush.Color := clwhite ;
out32($378,1);
form1.ADOTable2.Insert;
form1.ADOTable2.FieldByName('pin').As String := AdoTable3.Fields[1].AsString;
form1.ADOTable2.FieldByName('pass').As String :=
form1.ADOTable1.FieldByName('pa ss').AsString;
form1.ADOTable2.FieldByName('na ma').AsString :=
form1.ADOTable1.FieldByName('na ma').AsString;
form1.ADOTable2.FieldByName('ti mein').AsString :=
AdoTable3.Fields[2].AsString;
form1.ADOTable2.FieldByName('ti meout').AsString :=
AdoTable3.Fields[3].AsString;
form1.ADOTable2.FieldByName('bi aya').AsString := inttostr(hrgticket);
form1.ADOTable2.FieldByName('bu lanan').AsString := bulan;
form1.ADOTable2.Refresh; form1.ADOTable3.edit;
form1.ADOTable3.FieldByName('ke luar').AsString := '00:00:00';
form1.ADOTable3.Refresh; hrgticket := 0;
{printing output}
label3.Caption := ' Printing'; pin1 :=
form1.ADOTable2.FieldByName('pi n').AsString;
nama1 :=
form1.ADOTable2.FieldByName('na ma').AsString;
waktu1 :=
form1.ADOTable2.FieldByName('ti mein').AsString;
waktu2 :=
form1.ADOTable2.FieldByName('ti meout').AsString;
biaya1 :=
form1.ADOTable2.FieldByName('bi aya').AsString;
begin
Printer.BeginDoc;
Printer.Canvas.Font.Size := 11; Printer.Title := 'ParKirun';
Printer.Canvas.TextOut(100,100,' Sistem ParKirun ');
Printer.Canvas.TextOut(100,300,' Masuk :'+ waktu1 );
Printer.Canvas.TextOut(100,500,' Keluar :'+ waktu2 );
Printer.Canvas.TextOut(100,700,' User :'+ nama1 );
Printer.Canvas.Font.Size := 18; Printer.Canvas.TextOut(100,1000,' Biaya : '+ biaya1 );
Printer.Canvas.Font.Size := 12;
Printer.Canvas.TextOut(100,1200,'Terima kasih Atas Kunjungannya');
Printer.Canvas.TextOut(100,1400,' design by q-corp');
Printer.EndDoc; end;
cc :='keluar'; end; end;
edit2.text:=''; edit1.text:='';
timer2.Enabled := True ; label3.Caption := ' Ready'; end;
procedure TForm1.B1Click(Sender: TObject);
begin
form3.Show; end;
procedure TForm1.Timer3Timer(Sender: TObject);
var t1:string; begin
if(inp32($379))=207 then begin
t1:='1';
out32($378,1); cd:='ok'; end;
if(inp32($379))=15 then begin
out32($378,255);
cd:='ok'; end;
if cd ='ok' then
timer3.Enabled := False; end;
end.
;========================== ============
; Program keypad alpha numeric ; powered by annisa_KR'05 DM 5/51 ;========================== ============
LCD_RS bit P1.0
LCD_CS bit P1.1
kolom1 bit p2.3 ; kiri
(1,4,7,redial)
kolom2 bit p2.1 ;
atas (1,2,3)
kolom3 bit p2.5
baris1 bit p2.2 ;
1 2 3
baris2 bit p2.7 ;
ABC DEF
baris3 bit p2.6 ;
baris4 bit p2.4 ;
4 5 6
keyport equ P2 ;
GHI JKL MNO
old_key equ 40h ;
count_key equ 41h ;
7 8 9
keydata equ 42h ;
PQR STU VWX
alphacode equ 43h ;
n equ 44h ;
REDIAL 0 #
lama equ 45h ;
YZ[ ;<= space]-
;--- ; scanning tombol untuk alpha numerik
;---
org 0000h
jmp start
;
tulis: mov R4,#3
mov DPTR,#KIRUN
barisa: mov R3,#16
mov R1,#80h
acall write_inst0
ACALL LDELAY
tulis1: clr A
movc A,@A+DPTR
mov R1,A
Inc DPTR
acall write_data0
djnz R3,Tulis1
acall Ldelay
;
barisb: mov R3,#16
mov R1,#0C0h
acall write_inst0
acall Ldelay
tulis2: clr A
movc A,@A+DPTR
mov R1,A
Inc DPTR
acall write_data0
djnz R3,Tulis2
acall Ldelay
djnz R4,barisa
ret write_inst0:
clr lcd_rs ;untuk memuliskan
mov P0,R1 ;intruksi ke LCD
setb P1.1 ;module
clr P1.1
acall delay
ret ;
write_data0:
setb p1.0 ;untuk menuliskan
mov P0,R1 ;data ke LCD
setb P1.1 ;module
clr P1.1
acall delay
ret ;
mulai:
mov R1,#03Fh
acall write_inst0
acall write_inst0
mov R1,#0Dh
acall write_inst0
mov R1,#06h
acall write_inst0
mov R1,#01h
acall write_inst0
mov R1,#0Ch
acall write_inst0
acall tulis
ret
KIRUN: DB 'SELAMAT DATANG '
DB 'P A R K-I R U N '
DB 'UNIKA SOEPRA-FTI'
DB 'Phone8441555-139'
DB ' By KIRUN.CS ',0
text_nama:
db ' P A R K I R U N ',0 text_judul:
db ' 02.50.0080 ',0 ;
start: nop sensor1:
call mulai
jb p1.5,sensor2
ajmp out sensor2:
call mulai
jb p2.0,start
on:
call init_lcd mov dptr,#text_nama call tampilline1 mov dptr,#text_judul call tampilline2
call ldelay
mov r5,#20
; jb p2.0,$
; kemenu:
call init_lcd call disp_menu call ldelay clr a call init_lcd JMP alphanum sub1:
call ldelay call ldelay out:
ajmp menuout
;
call init_lcd
mov dptr,#text_menu2 call tampilline1 mov dptr,#text_menu1 call tampilline2
clr a
acall disp_menu12
;_lagi
jmp $ disp_menu: call init_lcd
mov dptr,#text_menu3 call tampilline1 mov dptr,#text_menu4 call tampilline2 ret
;============================== ==
text_menu3:
db ' Insert Pin ',0 text_menu4:
db ' Tekan Enter ',0
;============================== ==
disp_menu12: call init_lcd
mov dptr,#text_menu5 call tampilline1
mov dptr,#text_menu41 call tampilline2
ret
;============================== ===
text_menu5:
db' Insert Password ',0 text_menu41:
db ' Tekan Enter ',0
;============================== ===
disp_menu1: call init_lcd
mov dptr,#text_menu3 call tampilline1 mov dptr,#text_menu4 call tampilline2 ret
;============================== ===
disp_menu11: call init_lcd
mov dptr,#text_menu2 call tampilline1 mov dptr,#text_menu1 call tampilline2
ret text_menu2:
db ' PASSWORD ANDA ',0 text_menu1:
db ' PASTIKAN BENAR ',0 ;========================== =======
;tampilan karakter tampilline2: call line2 sjmp outchar tampilline1: call line1 sjmp outchar tampilcharloop: call write_data inc dptr outchar: clr a
movc a,@a+dptr jnz tampilcharloop ret
write_control:
clr LCD_CS clr lcd_RS ;rs=0 mov p0,a sjmp dlylcd1
dlylcd1:
setb LCD_CS mov r7,#250 djnz r7,$ clr LCD_CS ret
;line lcd line2:
mov a,#0c0h sjmp lineout line1:
mov a,#80h lineout:
call write_control ret
;================== ; Inisialisasi LCD
;================== init_lcd:
call Ldelay
mov A,#03Fh call write_inst call write_inst
mov A,#0Dh call write_inst mov A,#06h call write_inst mov A,#01h call write_inst mov A,#0Fh call write_inst
mov n,#07FH
RET ;
alphanum:
mov old_key,#0
mov count_key,#0
scan_alpha_numerik:
call keypad3x4
mov A,keydata
mov p3,keydata
;========
mov Old_key,A
mov alphacode,A
mov count_key,#0
call tampil
mov lama,keydata
call tunggu_tombol_dilepas
; cjne a,#0fh,key_pressed_1
cjne a,#0fh,scan_alpha_numerik
call tunggu_tombol_dilepas
;========
acall delay
mov p3,#00h
acall delay acall delay jnb p3.6,inbenar acall disp_menu
jmp alphanum
inbenar:
acall disp_menu12 acall ldelay
acall disp_menu11
pass:
acall keypad3x4 mov p3,keydata mov a,keydata acall tampil
call tunggu_tombol_dilepas
cjne a,#0fh,pass
call tunggu_tombol_dilepas
acall ldelay jnb p3.6,passbenar acall disp_menu12 jmp pass
passbenar:
call portalin acall mulai portalin:
mov r0,10 clr p3.4 clr p3.5 acall ldelay
clr p3.4 setb p3.5 acall ldelay setb p3.4 clr p3.5
acall ldelay
setb p3.4 setb p3.5 acall ldelay djnz r0,portalin
acall sebentar ;========
portaloff: jb p1.4,$ mov r0,10 setb p3.4 setb p3.5 acall ldelay setb p3.4 clr p3.5 acall ldelay clr p3.4 setb p3.5
acall ldelay
clr p3.4 clr p3.5 acall ldelay djnz r0,portaloff jnb p2.0,onlagi
jmp start onlagi:
ajmp on
; cjne
A,#0FFh,scan_alpha_numeri k
; cjne a,#2,cv
; ajmp sub1
;cv: acall putar_kanan
; ajmp start
; ajmp $
;key_pressed_1:
; orl A,#30h
; cjne A,Old_key,new_char
; mov Old_key,A
; inc count_key
; ;anl A,#0Fh
; ;mov B,#3
; ;mul AB
; ;add A,#3Ah
; ;add A,count_key
; cjne A,#5Eh,space
; mov A,#2Dh
; RET
;space: cjne A,#5Ch,not_space
; mov A,#20h
;not_space:
; mov alphacode,A
; call tampil
; mov lama,keydata
; call tunggu_tombol_dilepas
; mov A,count_key
; cjne A,#3,scan_alpha_numerik
; mov old_key,#0
; mov count_key,#0
; jmp scan_alpha_numerik
;new_char:
mov Old_key,A
mov alphacode,A
mov count_key,#0
call tampil
mov lama,keydata
call tunggu_tombol_dilepas
jmp scan_alpha_numerik
;
tunggu_tombol_dilepas:
jnb baris1,$
jnb baris2,$
jnb baris3,$
jnb baris4,$
ret
;============================== ======
menuout:
call init_lcd call disp_menu call ldelay clr a
call init_lcd JMP alphanum1
;==========================
tampil: mov A,keydata
cjne A,lama,naik
tterus: mov A,ALPHACODE
call write_data
mov A,n
call write_inst
ret
naik: cjne A,#0Fh,cek_BS
mov ALPHACODE,#20H
mov old_key,#0
mov lama,#0
mov keydata,#0FFh
mov count_key,#0
naik1: inc n
mov A,n
call write_inst
sjmp tterus
cek_BS: cjne
A,#0Eh,naik1
mov A,#20H
call write_data
dec n
mov A,n
cjne A,#80h,cekbkb
cekbkb: jnc terus9
mov A,#80h
mov n,#7Fh
terus9: call write_inst
mov old_key,#3Eh
mov count_key,#0
mov keydata,#0FFh
mov lama,#0
ret
;========================== ==========
; routine u/ baca keypad 3x4 ; output pd keydata(0-9,E=redial,F=#)
;========================== ==========
Keypad3x4:
mov keyport,#0FFh
clr kolom1
ul1: jb baris1,key1
mov keydata,#1
ret
key1: jb baris2,key2
mov keydata,#4
ret
key2: jb baris3,key3
mov keydata,#7
ret
key3: jb baris4,key4
mov keydata,#0Eh
ret
key4: setb kolom1
clr kolom2
jb baris1,key5
mov keydata,#2
ret
key5: jb baris2,key6
mov keydata,#5
ret
key6: jb baris3,key7
mov keydata,#8
ret
key7: jb baris4,key8
mov keydata,#0
ret
key8: setb kolom2
clr kolom3
jb baris1,key9
mov keydata,#3
ret
key9: jb baris2,key10
mov keydata,#6
ret
key10: jb baris3,key11
mov keydata,#9
ret
key11: jb baris4,key12
mov keydata,#0Fh
ret
key12: mov keydata,#0FFh
ret
;============================== ==========
alphanum1:
mov old_key,#0
mov count_key,#0
scan_alpha_numerik1:
call keypad3x4
mov A,keydata
mov p3,keydata
;========
mov Old_key,A
mov alphacode,A
mov count_key,#0
call tampil
mov lama,keydata
call
tunggu_tombol_dilepas
; cjne
a,#0fh,key_pressed_1 cjne
a,#0fh,scan_alpha_numerik1 call
tunggu_tombol_dilepas ;========
acall delay
mov p3,#00h
acall delay acall delay jnb p3.6,inbenar1 acall disp_menu
jmp alphanum1
inbenar1:
acall disp_menu12 acall ldelay
acall disp_menu11
pass1:
acall keypad3x4 mov p3,keydata mov a,keydata acall tampil call
tunggu_tombol_dilepas cjne a,#0fh,pass1 call
tunggu_tombol_dilepas acall delay
mov p3,#00h acall ldelay
jnb p3.6,passbenar1 acall disp_menu12 jmp pass1
passbenar1:
call portalin1 acall mulai portalin1:
mov r0,10 clr p1.6 clr p1.7 acall ldelay
clr p1.6 setb p1.7 acall ldelay
setb p1.6 clr p1.7
acall ldelay
setb p1.6 setb p1.7 acall ldelay djnz r0,portalin1
acall sebentar ;========
portaloff1: jb p1.5,$ mov r0,10 setb p1.6 setb p1.7 acall ldelay setb p1.6 clr p1.7 acall ldelay clr p1.6 setb p1.7
acall ldelay
clr p1.6 clr p1.7 acall ldelay djnz r0,portaloff1 jnb p2.0,onlagi1
jmp start onlagi1:
ajmp on ret
;============================== ==========
; Routine untuk menulis instruksi ke LCD ;============================== ==========
write_inst:
clr LCD_RS setb LCD_CS
mov P0,A ;intruksi ke LCD clr LCD_CS ;module setb LCD_CS
call delay ret
;============================== ==========
; Routine untuk menulis data ke LCD ;============================== ==========
write_data:
setb LCD_RS setb LCD_CS
mov P0,A ;data ke LCD
clr LCD_CS ;module setb LCD_CS
call delay ret
;========================= ; Routine penghasil delay
;========================= delay: mov R0,#50
delay1: mov R5,#0 djnz R5,$ djnz R0,delay1 ret
;
Ldelay: mov R2,#010h Ld1: call delay
djnz R2,Ld1 ret
sebentar:
call dlybounc djnz r5,sebentar ret
dlybounc:
mov r6,#100 loopb2:
mov r7,#250 loopb1:
nop nop nop
djnz r7,loopb1 djnz r6,loopb2 ret
;========================== ==========
; routine u/ baca keypad 3x4 ; output pd keydata(0-9,E=redial,F=#)
;========================== ==========
Keypad3x41:
mov keyport,#0FFh
clr kolom1
ul_1: jb baris1,key_1
mov keydata,#1
ret
key_1: jb baris2,key_2
mov keydata,#4
ret
key_2: jb baris3,key_3
mov keydata,#7
ret
key_3: jb baris4,key_4
mov keydata,#0Eh
ret
key_4: setb kolom1
clr kolom2
jb baris1,key_5
mov keydata,#2
ret
key_5: jb baris2,key_6
mov keydata,#5
ret
key_6: jb baris3,key_7
mov keydata,#8
ret
key_7: jb baris4,key_8
mov keydata,#0
ret
key_8: setb kolom2
clr kolom3
jb baris1,key_9
mov keydata,#3
ret
key_9: jb baris2,key_10
mov keydata,#6
ret
key_10: jb baris3,key_11
mov keydata,#9
ret
key_11: jb baris4,key_12
mov keydata,#0Fh
mov p3,#0eh
ajmp disp_menu_baru
ret
key_12: mov keydata,#0FFh
ret ;
Mulaii: Nop
Mov R3,#0EFh
Keyscan:
jb P3.0,key0
Mov R2,#50
Lcall Putar_kiri
key0: jb P3.1,keyscan
Mov R2,#50
Lcall Putar_kanan ret
;
disp_menu_baru: call init_lcd
mov dptr,#text_menu6 call tampilline1 mov dptr,#text_menu7 call tampilline2 ret
;========================== =======
text_menu6:
db ' 1.Buka Pintu ',0 text_menu7:
db ' 2.Ganti Password',0 ;========================== =======
Putar_kanan:
Mov R3,#0EFh
mov r2,#50
Mov A,R3
RL A
Cjne A,#0FEh,Lanjut1
Mov R3,#0EFh
Mov A,#0EFh
Lanjut1:
Mov P3,A
Mov R3,A
Lcall LDelay2
Mov P3,#0FFh ;
matikan motor
Djnz R2,Putar_kanan
Ret ;
Putar_kiri:
Mov A,R3
RR A
Cjne A,#0F7h,Lanjut
Mov R3,#7Fh
Mov A,#7Fh
Lanjut:
Mov P3,A
Mov R3,A
Lcall LDelay2
Mov P3,#0FFh
Djnz R2,Putar_kiri
Ret
;--- ; sub routine delay ;---
Ldelay2: Mov R1,#200 ;
delay ini tergantung dari x-tal
Delay2: Mov R0,#0h ; yang
dipasang
Djnz R0,$ ;
Djnz R1,Delay2
Ret ;
;
end