PDA

View Full Version : Đo nhiệt độ hiển thị LCD dùng LM35 và PIC 16F877A


meohaplasen
19-11-2013, 12:47 AM
đây là code và hình ảnh mô phỏng proteus của mình - viết bằng CCS C. Mô phỏng thì chạy nhưng mạch in thực tế thì ko hiển thị được nhiệt độ. Mọi người giúp mình với vì mình mới học về PIC nên còn gà mờ lắm :D

#define <16f877a.h>
#include <16F877A.h>
#device *=16adc=8
#use delay(clock=12000000)
#FUSES NOWDT,HS,NOPUT,NOPROTECT,NODEBUG,NOBROWNOUT,NOLVP, NOCPD,NOWRT
#define LCD_ENABLE_PIN PIN_D2
#define LCD_RS_PIN PIN_D0
#define LCD_RW_PIN PIN_D1
#define LCD_DATA4 PIN_D4
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7
#include <lcd_4bit.c>
int8 read;
void main()
{
//set_tris_b(0);
set_tris_a(0xFF);
set_tris_d(0x00);
//Khoi tao ADC
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
set_ADC_channel(0);
delay_ms(50);
lcd_init();
read=read_adc();
read=read*2;
printf(hienthi,"\rNhiet do:%u",read);
}