I have designed a PIC18F877A micro controller project to read temperature from an LM35 using ADC, display it on an LCD and transmit it to a serial port.
When the program starts, sometimes it shows a startup message - sometimes it doesn't display anything. Also, the serial port connection is not working. Can anyone help - am I missing something? Are there any ground connections missing?
My code:
#include <16F877A.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232 (baud=9600,rcv=PIN_C7, xmit=PIN_C6)
#include <lcd.c>
float value;
float temp;
float temp2;
float temp3;
float temp4;
float temp5[14];
float count[14];
int c;
void main(void)
{
//setup_adc_ports( ALL_ANALOG );//Initialize and Configure ADC
//setup_adc(ADC_CLOCK_INTERNAL );
while(1)
{
lcd_init();
lcd_gotoxy (1,1);
delay_ms(1000);
printf(lcd_putc," WELCOME TO\n Micro Tech Sol.");
delay_ms(3000);
lcd_gotoxy (1,1);
printf(lcd_putc," Fuel Monitoring \n PROJECT ");
delay_ms(3000);
}
}
lcd_init()
is in thewhile(1)
loop. You're initializing the LCD continuously! \$\endgroup\$