那位高手能用Keil uVision3 编51单片机程序。下面是个流水灯的程序,谁可以帮我加一个开始和停止的按键,
开始停止按键的输入信号。引脚顺便定义。最好是P0.1很P0.0口ORG0X0000LJMPSTARTSTART:MOVA,#0XFELOOP:RLAMOVP1,ALCAL...
开始停止按键的输入信号。引脚顺便定义。 最好是 P0.1 很P0.0口
ORG 0X0000
LJMP START
START: MOV A,#0XFE
LOOP: RL A
MOV P1,A
LCALL DELAY
SJMP LOOP ;延时程序
DELAY: MOV R5,#200
OUT: MOV R6,#250
OUT1: MOV R7,#250
IN: DJNZ R7,$
DJNZ R6,OUT1
DJNZ R5,OUT
RET
END 展开
ORG 0X0000
LJMP START
START: MOV A,#0XFE
LOOP: RL A
MOV P1,A
LCALL DELAY
SJMP LOOP ;延时程序
DELAY: MOV R5,#200
OUT: MOV R6,#250
OUT1: MOV R7,#250
IN: DJNZ R7,$
DJNZ R6,OUT1
DJNZ R5,OUT
RET
END 展开
3个回答
展开全部
:
ORG 0X0000
LJMP START
START:
MOV A, #0XFE
LOOP:
jnb F0, key ;F0=0 就转移,不显示.
;------------------------------------------
RL A
MOV P1, A
LCALL DELAY
;------------------------------------------
key:
jnb P0.0, key2 ;P0.0=0,按键按下就转移.
SJMP LOOP ;没按,就继续.
key2:
mov r5, #1 ;延时短一点.
call OUT ;延时消抖.
jb P0.0, LOOP ;松开就不算按下.
jnb P0.0, $ ;等待释放.
cpl F0 ;控制位取反.
SJMP LOOP ;继续.
;-------------------------------------------
DELAY: ;延时程序.
MOV R5,#200
OUT: MOV R6,#250
OUT1: MOV R7,#250
IN: DJNZ R7,$
DJNZ R6,OUT1
DJNZ R5,OUT
RET
END
ORG 0X0000
LJMP START
START:
MOV A, #0XFE
LOOP:
jnb F0, key ;F0=0 就转移,不显示.
;------------------------------------------
RL A
MOV P1, A
LCALL DELAY
;------------------------------------------
key:
jnb P0.0, key2 ;P0.0=0,按键按下就转移.
SJMP LOOP ;没按,就继续.
key2:
mov r5, #1 ;延时短一点.
call OUT ;延时消抖.
jb P0.0, LOOP ;松开就不算按下.
jnb P0.0, $ ;等待释放.
cpl F0 ;控制位取反.
SJMP LOOP ;继续.
;-------------------------------------------
DELAY: ;延时程序.
MOV R5,#200
OUT: MOV R6,#250
OUT1: MOV R7,#250
IN: DJNZ R7,$
DJNZ R6,OUT1
DJNZ R5,OUT
RET
END
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询