;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 ;-------------------------------------------------------------