Documentos de Académico
Documentos de Profesional
Documentos de Cultura
2MV8 P07 Toledo Lopez
2MV8 P07 Toledo Lopez
PRÁCTICA 7
UNIDAD DE APRENDIZAJE
MICROPOCESADORES, MICROCONTROLADORES E INTERFAZ
PROFESOR
//Declarar variables
int lecturaADC_A0; //Variable donde se guarda la lectura del ADC
char *text; //Apuntador para el texto
char valorText[6]; //Arreglo de caracteres donde se guarda el valor del
texto
float volts_A0; //Valor en volts de la lectura en A0
void main() {
LCD_Init(); //Inicializacion del LCD
LCD_Cmd(_LCD_CURSOR_OFF); //Comando LCD para apagar
el cursor
LCD_Cmd(_LCD_CLEAR); //Comando LCD para borrar
LCD
Programa 2
//Conexiones del LCD
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
//Declarar variables
int lecturaADC_A0; //Variable donde se guarda la lectura del ADC
char *text; //Apuntador para el texto
char valorText[6]; //Arreglo de caracteres donde se guarda el valor del
texto
float volts_A0; //Valor en volts de la lectura en A0
void main() {
LCD_Init(); //Inicializacion del LCD
LCD_Cmd(_LCD_CURSOR_OFF); //Comando LCD para apagar
el cursor
LCD_Cmd(_LCD_CLEAR); //Comando LCD para borrar
LCD
while(1){
lecturaADC_A0=ADC_Read(0); //Conversion
A/D. Pin RA0 es una entrada
volts_A0=5*(float)lecturaADC_A0/1023; //Valor en
milivoltios
FlotanteATexto((volts_A0-1.2)/0.085); //El valor se
convierte a texto
LCD_Out(2,1,valorText); //Se escribe el
valor en el LCD en la fila 2, columna 6
LCD_Chr_CP(223); //Se escribe °
en la posicion actual del cursor
LCD_Chr_CP('C'); //Se escribe C
en la posicion actual del cursor
Delay_ms(10); //Retardo de
10ms
}
}
Ilustración 1 Programa 1
Ilustración 2 Programa 2