Ticker

6/recent/ticker-posts

How to make count up 00 to 99 using 7 Segment Display

 
This is my project subject microcontroller and i want to share for who want to try it or make assignment about this. I have tuning this program assembly when click pattern it will increment and when click stop button it reset to 00.




Firstly , I made a schematic circuit in Proteus and  write program in Keil Uvision3 and perform simulation.You can see circuit that i have make.If your simulation going ok you can make circuiT.


IMPORTANT: ANY CONNECTION SHOULD FOLLOW THE SCHEMATIC DIAGRAM TO AVOID THE COMPONENTS FROM DAMAGE. 



Circuit 

Assembly Program 

       Org    00H
        data_one    equ    P3
        data_ten    equ    P2
    IPIN        EQU    P1.0
    DPIN        EQU    P1.1
        Mynumber    Equ    30H 

main_prog:  
    CALL INIT
AGAIN:

AG2:    JB IPIN,AG1
    CALL DELAY1    ;debounce
    JB IPIN,AG1
    JNB IPIN,$    ;wait till switch release
    INC MYNUMBER
    mov a,mynumber
    cjne a,#100,pq1
    mov mynumber,#0
pq1:
    call bcd    ;diaplay data


AG1:    JB DPIN,AG2
    CALL DELAY1
    JB DPIN,AG2
    JNB DPIN,$   
    clr mynumber     
    mov a,#0C0H
    cjne a,#0C0H,pq2
    mov mynumber,#00
pq2:
    call bcd
    JMP AGAIN


INIT:
    MOV    data_ten,#0C0H
        MOV    data_one,#0c0H
        mov    Mynumber,#0
        mov    p1,#255        ;set port 1 as input BY . IT SHOULD BE 1
RET

DELAY1:    MOV R4,#255
    DJNZ R4,$
RET
   
BCD:    Mov     A,Mynumber
        Mov     B,#10
        Div    AB    

    mov dptr,#seg_conv 
    MOVC A,@A+DPTR    ; MOVE DATA @A+DPTR IN A     
        mov    data_ten, A  

        mov    A,B
        mov dptr,#seg_conv 
    MOVC A,@A+DPTR    ; MOVE DATA @A+DPTR IN A     
        mov    data_one, A  
Ret

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
    
Seg_conv:  
    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

        END

Catat Ulasan

0 Ulasan