Estaba haciendo otra prueba pero no me sale en asm.
Con un sólo pulsador quiero hacer esto.
- Si pulso RA4 una vez, se activa los ventiladores y enciende el aparato. El Led Verde enciende, Rojo y Naranja apagado.
- Si vuelvo a pulsar el mismo pulsador RA4, se apaga el aparato, los ventiladores se quedan encendido al menos 2 minutos, Led se apaga el Verde, Rojo apagado y Naranja encendido.
- Cuando pasen los 2 minutos, todos los Led apagado menos el Rojo que se enciende y se queda ahí.
Ver esquema.
http://www.subeimagenes.com/img/tacometro-23732.jpg
Código:
************************************* VentiladorDC_01.asm **********************************
;
;
;
; ZONA DE DATOS **********************************************************************
LIST P=16F84A
INCLUDE <P16F84A.INC>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
CBLOCK 0x0C
Flag
ENDC
#DEFINE Led_Naranja PORTA,0 ;
#DEFINE Tacometro1 PORTA,1 ; Tacómetro del ventilador 1.
#DEFINE Tacometro2 PORTA,2 ; Tacómetro del ventilador 2.
#DEFINE Led_Azul_tacometro_2 PORTA,3 ; Interruptor
#DEFINE Activar_Ventilador PORTA,4 ; Interruptor
#DEFINE Led_Verde PORTB,0 ;
#DEFINE Led_Rojo PORTB,1 ;
#DEFINE Ventilador1 PORTB,2 ;
#DEFINE Ventilador2 PORTB,3 ;
#DEFINE Canal1 PORTB,4 ;
#DEFINE Canal2 PORTB,5 ;
#DEFINE Ventilador3 PORTB,6 ;
#DEFINE Ventilador4 PORTB,7 ;
; ZONA DE CÓDIGOS ********************************************************************
ORG 0
Inicio
bsf STATUS,RP0
bcf Led_Naranja
bsf Tacometro1
bsf Tacometro2
bcf Led_Azul_tacometro_2
bsf Activar_Ventilador
clrf TRISB ; Las líneas del Puerto B configuradas como salida.
bcf STATUS,RP0
bcf Led_Naranja
bcf Led_Azul_tacometro_2
Principal
clrw ; Con esta combinación se detiene el motor.
DejaPulsar
btfss Activar_Ventilador
goto Vent_ON
goto DejaPulsar
Vent_ON
movlw .1
movwf Flag
movlw b'11111101' ; Encender ventiladores.
goto ActivaSalida
Vent_OFF
bsf Led_Naranja
call Retardo_2s
movlw b'11001110' ; Apagar ventiladores.
bcf Led_Naranja
goto ActivaSalida
ActivaSalida
movwf PORTB
btfss Flag,0
goto Vent_OFF
goto Principal
INCLUDE <RETARDOS.INC>
END