Tengo que hacer un termostato programable pero primero vamos por partes.El programa que tengo para el pic me visualiza los grados enteros,pero me gustaría que los grados fuesen decimales,29,5;30,5...Aqui os dejo el programa,espero que alguien me pueda alludar.Gracias por adelantado.
PROGRAMA:
#include <pic.h>
#include "LCD.h"
#include <stdio.h>
// Para el PIC16F87x
__CONFIG(WDTDIS & XT & UNPROTECT & PWRTDIS & LVPDIS );
void PintaMensaje(unsigned int temp)
{
unsigned char i=0;
char M[16];
unsigned long t = (temp*500L)>>16;
LCD_Comando(LCDCasa);
sprintf(M,"T1= %7d C",(unsigned int)t);
while( M!=0 ) LCD_Caracter( M[i++] ); // Pinta
}
void main()
{
unsigned int t1;
ADCON1 = B00000000; // PORTA anal´ogico, justif. a la izquierda
LCD_Port(); // Inicia los puertos
LCD_Reset(); // Inicia el LCD
while(1) // Bucle infinito
{
ADCON0 = B11000001;
ADIF = 0; // Borro indicador de fin de conversion
ADGO = 1; // Inicia la conversion AD
while(!ADIF);
t1=ADRESH<<8|ADRESL;
PintaMensaje(t1);
}
}
Soy novato en esto,si esta mal el tema dnd esta decidmelo que lo posteo en otro sitio.Gracias
PROGRAMA:
#include <pic.h>
#include "LCD.h"
#include <stdio.h>
// Para el PIC16F87x
__CONFIG(WDTDIS & XT & UNPROTECT & PWRTDIS & LVPDIS );
void PintaMensaje(unsigned int temp)
{
unsigned char i=0;
char M[16];
unsigned long t = (temp*500L)>>16;
LCD_Comando(LCDCasa);
sprintf(M,"T1= %7d C",(unsigned int)t);
while( M!=0 ) LCD_Caracter( M[i++] ); // Pinta
}
void main()
{
unsigned int t1;
ADCON1 = B00000000; // PORTA anal´ogico, justif. a la izquierda
LCD_Port(); // Inicia los puertos
LCD_Reset(); // Inicia el LCD
while(1) // Bucle infinito
{
ADCON0 = B11000001;
ADIF = 0; // Borro indicador de fin de conversion
ADGO = 1; // Inicia la conversion AD
while(!ADIF);
t1=ADRESH<<8|ADRESL;
PintaMensaje(t1);
}
}
Soy novato en esto,si esta mal el tema dnd esta decidmelo que lo posteo en otro sitio.Gracias
Última edición por un moderador: