Nik Zhafran
Junior Member level 1
- Joined
- Feb 23, 2015
- Messages
- 15
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Location
- Shinjuku-ku, Tokyo, Japan, Japan
- Activity points
- 134
Count up 00 to 99
How to make program when each time pattern press it incress one by one ( number 0 then we press pattern it will 1 and press again it be 2 ,press again it be 3 and to 99 )
How to program when i click pushbotton stop it will reset ...
can anyone tuning this code because this code i push the button it increment directly 00 to 99 ... .....
and when click stop it decrement ...
HTML:
Org 00H
data_one equ P3
data_ten equ P2
Mynumber Equ 30H
main_prog:
MOV data_ten,#0C0H
MOV data_one,#0c0H
mov Mynumber,#0
mov p1,#0 ;set port 1 as input
JB P1.0,up_A
JB P1.1,stop_A
sjmp main_prog
up_A: mov a, Mynumber
Cjne A,#99, up
mov Mynumber,#0FFH
sjmp up
stop_A: mov a, Mynumber
Cjne A,#0, stop
mov Mynumber,#99H
sjmp stop
up: inc Mynumber
JB P1.1,stop
Call BCD
call delay
mov a, Mynumber
Cjne A,#99, up
mov Mynumber,#0FFH
SJMP main_prog
stop: dec Mynumber
JB P1.0,up
Call BCD
call delay
mov a, Mynumber
Cjne A,#00, stop
mov Mynumber,#100
SJMP main_prog
BCD: Mov A,Mynumber
Mov B,#10
Div AB
call Seg_conv
mov data_ten, A
mov A,B
call Seg_conv
mov data_one, A
Ret
Seg_conv: inc A
Movc A, @A+PC
RET
DB 0C0H ; 0
DB 0F9H ; 1
DB 0A4H ; 2
DB 0B0H ; 3
DB 099H ; 4
DB 092H ; 5
DB 082H ; 6
DB 0F8H ; 7
DB 080H ; 8
DB 090H ; 9
delay: MOV R5,#0ffh
MOV R6,#0ffH
MOV R7,#2
delay_loop: DJNZ R5,delay_loop
DJNZ R6,delay_loop
DJNZ R7,delay_loop
RET
END