新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > 花樣流水燈的設計1(單片機-匯編)

        花樣流水燈的設計1(單片機-匯編)

        作者: 時間:2016-11-29 來源:網絡 收藏
        ;This program will show you cycle glitter between 8 led lamps
        ; maker:Chen Weiwu
        ; date:2012-11-08
        ; version:1.0.0
        ;-------------------------------------------------------------
        ;Define
        Ledprt equ p0
        SegDisPlay equ p2
        L1 equ 30h
        l3 equ 32h
        button1 equ p1.0
        button2 equ p1.2
        button3 equ p1.4
        button4 equ p1.6
        ;----------------------
        ;Set the initiation address which the program runing
        ;----------------------
        org 0
        ajmp main
        ;----------------------
        Pattern1:
        mov a,#11111110B
        Cycle1: mov Ledprt,a
        rl a
        acall delay
        jnb button1,cycle1
        mov Ledprt,#11111111B
        ret
        ;-----------------------
        Pattern2:
        mov a,#01111111B
        mov l1,#00000001B
        Cycle2: mov l3,a
        xrl a,l1
        mov Ledprt,a
        mov a,l3
        rl a
        mov l3,a
        mov a,l1
        rr a
        mov l1,a
        mov a,l3
        acall delay
        jnb button2,cycle2
        mov Ledprt,#11111111B
        ret
        ;-----------------------
        Pattern3:
        mov a,#10101010B
        Cycle3: mov l1,a
        mov Ledprt,a
        acall delay
        mov a,#11111111B
        mov Ledprt,a
        acall delay
        mov a,l1
        rl a
        jnb button3,cycle3
        mov Ledprt,#11111111B
        ret
        ;-----------------------
        Pattern4:
        mov a,#11111110B
        mov l1,#00000001B
        Cycle4: mov Ledprt,a
        acall delay
        rl a
        xrl a,l1
        jnb button4,cycle4
        mov Ledprt,#11111111B
        ret
        ;-----------------------
        ;-----------------------
        ;delay section
        delay: mov r5,#50
        delay1: mov r6,#100
        DELAY2: mov r7,#10
        djnz r7,$
        djnz r6,delay2
        djnz r5,delay1
        ret
        ;-----------------------
        main: mov SegDisPlay,#00H
        jb button1,To2
        mov SegDisPlay,#01H
        Acall Pattern1
        To2:
        jb button2,To3
        mov SegDisPlay,#02H
        Acall Pattern2
        To3:
        jb button3,To4
        mov SegDisPlay,#03H
        Acall Pattern3
        To4:
        jb button4,main
        mov SegDisPlay,#04H
        Acall Pattern4
        ajmp Main
        ;-----------------------
        end
        ;-------------------------------------------------------------


        評論


        技術專區

        關閉
        主站蜘蛛池模板: 乃东县| 门源| 资中县| 山丹县| 达日县| 北安市| 任丘市| 富源县| 通榆县| 常德市| 崇阳县| 兰坪| 鸡泽县| 两当县| 浪卡子县| 方山县| 阿拉尔市| 萨嘎县| 雷州市| 岳西县| 集贤县| 方山县| 中超| 赫章县| 扬州市| 绿春县| 景德镇市| 和田市| 通城县| 庄浪县| 通州市| 大姚县| 寻甸| 响水县| 安福县| 萨迦县| 察雅县| 泸西县| 莫力| 保定市| 高阳县|