You are on page 1of 2

/*

* File: ejemplo1.c
* Author: Alumno
*
* Created on 12 de noviembre de 2019, 03:49 PM
*/

#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)


#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial
Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for
programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data
EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write
protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code
protection off)

// #pragma config statements should precede project file includes.


// Use project enums instead of #define for ON and OFF.

#include <xc.h>
#define _XTAL_FREQ 20000000

unsigned int caballero;


unsigned int num;

void multiplicacion ()
{
caballero=num*5;
}
void puertos ()
{
TRISB=0;
TRISC=255;
PORTB=0;
PORTC=0;
}

void main(void) {

puertos();

while(1){
num=PORTC;
multiplicacion();

switch (caballero)
{
case 0: TRISBbits.RB0=1; break;
case 5: TRISBbits.RB1=1; break;
case 10: TRISBbits.RB2=1; break;
case 15: TRISBbits.RB3=1; break;
case 20: TRISBbits.RB4=1; break;
case 25: TRISBbits.RB5=1; break;
case 30: TRISBbits.RB6=1; break;
case 35: TRISBbits.RB7=1; break;
default: PORTB=0;

}
}
return;

You might also like