⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teclado_3x4.inc

📁 Home made 4x3 keyboard library for PIC microcontrollers. Fast and simple.
💻 INC
字号:
;
;	 	 	  RB4  RB5  RB6 
;		 	   ^    ^    ^    
;			|----|----|----|
;	RB0 -->	|  1 |  2 |  3 |
;			|----|----|----|
;	RB1 -->	|  4 |  5 |  6 |
;			|----|----|----|
;	RB2 -->	|  7 |  8 |  9 |
;			|----|----|----|
;	RB3 -->	|  A |  0 |  B |
;			|----|----|----|
;
	

;********************************************************************************
Teclado_Inicializa
	bsf		STATUS,RP0				; banco 1
	movlw	b'11110000'				; <RB6:RB4> entradas, <RB3:RB0> salidas
	movwf	TRISB
	bcf		OPTION_REG,7		; Habilita resistencia de Pull-Up del Puerto B(todas)
	bcf		STATUS,RP0				; Acceso al banco 0.

	call	Teclado_EsperaDejePulsar

	return
;
; Subrutina "Teclado_EsperaDejePulsar" --------------------------------------------------
;
;Permanece en esta subrutina mientras siga pulsada la tecla.
;
Teclado_Comprobacion	EQU	b'11110000'

Teclado_EsperaDejePulsar:
	movlw	b'11110000'				; Pone a cero las cuatro l韓eas de salida del 
	movwf	PORTB					; Puerto B(4 de la derecha).
Teclado_SigueEsperando 
	call	Retardo_20ms			; Espera a que se estabilicen los niveles de tensi髇.
	movf	PORTB,W					; Lee el Puerto B.
	sublw	Teclado_Comprobacion	; Si es lo mismo es que ya no pulsa 
	btfss	STATUS,Z				; tecla alguna.
	goto	Teclado_SigueEsperando

	return

;********************************************************************************


LeeTecla

	;escaneo fila 1
            movlw   b'11111110'		; RB0 a 0 (resistencias pull up)
            movwf   PORTB
			call	Retardo_1ms

;inicializo variable Tecla

            btfss   PORTB,4	; si esta a 1 sigue buscando
			goto	uno				; si esta a 0 es nuestra tecla

            btfss   PORTB,5
			goto	dos

            btfss   PORTB,6
			goto	tres
        
	;escaneo fila 2
            movlw   b'11111101'		; RB1 a 0
            movwf   PORTB
			call	Retardo_1ms

            btfss   PORTB,4
			goto	cuatro
            btfss   PORTB,5
			goto	cinco
            btfss   PORTB,6
			goto	seis



	;escaneo fila 3
            movlw   b'11111011'		; RB2 a 0
            movwf   PORTB
			call	Retardo_1ms

            btfss   PORTB,4
			goto	siete
            btfss   PORTB,5
			goto 	ocho
            btfss   PORTB,6
			goto	nueve

	;escaneo fila 4
            movlw   b'11110111'		; RB3 a 0
            movwf   PORTB
			call	Retardo_1ms

            btfss   PORTB,4
			goto	asterisco
            btfss   PORTB,5
			goto	cero
            btfss   PORTB,6
			goto 	almohadilla

fintecla
	return

;**********************************************************************

uno	
	movlw	0x01
	goto	fintecla
dos
	movlw	0x02
	goto	fintecla
tres
	movlw	0x03
	goto	fintecla
cuatro
	movlw	0x04
	goto	fintecla
cinco
	movlw	0x05
	goto	fintecla
seis
	movlw	0x06
	goto	fintecla
siete
	movlw	0x07
	goto	fintecla
ocho
	movlw	0x08
	goto	fintecla
nueve
	movlw	0x09
	goto	fintecla
cero
	movlw	0x00
	goto	fintecla
asterisco
	movlw	0x0A
	goto	fintecla
almohadilla
	movlw	0x0B
	goto	fintecla

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -