This document contains code for a PIC microcontroller that controls 6 LEDs based on the position of 2 selector switches. It defines the LED and switch pins, clears the LEDs initially, then enters a main loop that checks the selector switches and calls different subroutines to light the LEDs individually or in sequence depending on the switch position.
1 of 3
Download to read offline
More Related Content
Codigo 6leds
1. LIST P=16F84A
INCLUDE<P16F84A.INC>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
CBLOCK 0X0C
ENDC
#DEFINE LED1 PORTB,0
#DEFINE LED2 PORTB,1
#DEFINE LED3 PORTB,2
#DEFINE LED4 PORTB,3
#DEFINE LED5 PORTB,4
#DEFINE LED6 PORTB,5
#DEFINE SELECTOR_1 PORTA,0
#DEFINE SELECTOR_2 PORTA,1
ORG 0
INICIO
BSF STATUS,5; ir al banco
BCF LED1 ; salida poniendo a cero
BCF LED2
BCF LED3
BCF LED4
BCF LED5
BCF LED6
BSF SELECTOR_1
BSF SELECTOR_2
BCF STATUS,5 ; volver al banco 0
CLRF PORTB ;limpiar el puertoB
PRINCIPAL
CALL Retardo_10ms
BTFSC SELECTOR_1 ; posicion del selector
GOTO PRINCIPAL
LAZO MOVF PORTA,W ; se toma el valor del puerto
ANDLW B'00000011' ; filtra los dos valores
ADDWF PCL,F ; suma con el PCL y se obtine la pos tabla
TABLA GOTO MINIMO
GOTO LAZO
GOTO MAXIMO
GOTO LAZO
MINIMO
CALL INYECTOR_1
CALL Retardo_1s