# PRACTICA 1

:
// ENCENDER LED
void main() {
TRISD = 0; //TRIS CONFIGURA EL PUERTO D COMO SALIDA
PORTD = 0; //SE INICIALIZA EL PUERTO D EN ESTADO BAJO (APAGADO)
while(1){
PORTD = 255; //MANDO UN 1 LOGICO AL PUERTO DE SALIDA D
Delay_ms(300); //ESTE PERMANECERA ENCENDIDO POR 300 ms
PORTD = 0; //APAGO EL LED, MANDO UN CERO LOGICO AL PUERTO D
Delay_ms(300); // APAGO EL LED POR 300ms
}
}
PRACTICA 2:
// ENTRADA DE DATOS A TRAVES DE PULSADORES
#define BOTON1 PORTA.RA0 // DEFINICION DE LOS PUERTOS A TRAVES DE UNA VARIABLE.
#define BOTON2 PORTA.RA1
#define BOTON3 PORTA.RA2
#define BOTON4 PORTA.RA3
void main() {
TRISA = 1; //TRIS CONFIGURA EL PUERTO A COMO ENTRADA
PORTA = 0;
TRISD = 0; //TRIS CONFIGURA EL PUERTO D COMO SALIDA
PORTD = 0; //SE INICIALIZA EL PUERTO D EN ESTADO BAJO (APAGADO)
ADCON1 = 0X06; //Pines RA<5:0> como E/S digital.
while(1){
if (BOTON1 == 1){
PORTD.RD0 = PORTD.RD1 = 1;
delay_ms(500);
}
else{
PORTD.RD0 = PORTD.RD1 = 0;
}
if (BOTON2 == 1){

RD3 = 1. sbit LCD_D5 at RB3_bit.RD3 = 0. delay_ms(500). sbit LCD_EN_Direction at TRISB1_bit. } else{ PORTD. sbit LCD_EN at RB1_bit. } else{ PORTD. } if (BOTON4 == 1){ PORTD.RD2 = PORTD.RD5 = 0.RD4 = PORTD.RD7 = 0.RD7 = 1. sbit LCD_D7 at RB5_bit.RD5 = 1. sbit LCD_D6 at RB4_bit. sbit LCD_RS_Direction at TRISB0_bit.RD6 = PORTD. sbit LCD_D4 at RB2_bit. . delay_ms(500).RD6 = PORTD. delay_ms(500).RD4 = PORTD. } if (BOTON3 == 1){ PORTD. } else{ PORTD. } } } PRACTICA 3: // CONVERTIDOR ANALOGICO DIGITAL Y LCD sbit LCD_RS at RB0_bit.PORTD.RD2 = PORTD.

PORTD = 0. i.txt). sbit LCD_D6_Direction at TRISB4_bit.1. valor1. TRISD = 7. void main() { TRISA = 255. TRISB = 0. while(1){ adc_rd = ADC_Read(4)/4. txt1 [7]. valor1 = 0. } } . unsigned int adc_rd. char txt [7]. PORTB = 0.sbit LCD_D4_Direction at TRISB2_bit. Lcd_Cmd(_LCD_Clear). ADCON1 = 0X89. Lcd_Init().txt). sbit LCD_D7_Direction at TRISB5_bit. inttostr(adc_rd. Lcd_Cmd(_LCD_Cursor_OFF). sbit LCD_D5_Direction at TRISB3_bit. adc_rd = 0. lcd_out(1.