#include <16F877A.h> // PIC a utilizar
#FUSES XT // Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOWDT // No Watch Dog Timer
#FUSES NOPUT // No Power Up Timer
#FUSES NOPROTECT // Code not protected from reading
#FUSES NODEBUG // No Debug mode for ICD
#FUSES NOBROWNOUT // No brownout reset
#FUSES NOLVP // No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD // No EE protection
#FUSES NOWRT // Program memory not write protected
#use delay(clock=4000000) // Oscilador a 4MHz
#byte PORTA=0x05 // Dirección del PortA
#byte PORTB=0x06 // Dirección del PortB
// FUNCION PRINCIPAL
void main(void){
set_tris_b(0b11111111); // Definimos PORTA como entrada
set_tris_b(0b00000000); // Definimos PORTB como salida
portb = 0x00; // Limpiamos Puerto B
while(TRUE){ // Bucle infinito
if(PORTA == 13){ // Comparamos el dato del puerto B con el dato 13
PORTB = 0b11111111; // Enciendo todos los LED
}
else{ // Opcion cuando es distinto
PORTB = 0b01010101; // Enciendo Led pares
}
}
}