BÀI 17 : ĐỌC GIÁ TRỊ ADC XUẤT RA LED VÀ LCD PIC16F877A CCS

6:26:00 PM
Về phần lý thuyết các bạn đọc Datasheet hoặc lên mạng tìm hoặc qua bên TUT về PIC16F877A XC8 tìm đọc nha !
- Đây là ảnh mô phỏng protues.

adc pic16f877a ccs

- Đây là code chương trình.
#include <16f877a.h>
#device 16f877a*16ADC=10
#use delay(clock=4000000)
#include <lcd_lib_4bit.c>
float x;
void ADC_init();
void main()
{
LCD_Init();
set_tris_a(0x01);
set_tris_b(0x00);
output_b(0x00);
while(true)
{
ADC_init();
x=read_ADC();
LCD_PutCmd(0x80);
LCD_PutChar("   Demo ADC");
LCD_PutCmd(0xC0);
printf(LCD_PutChar,"Value is :%f",x);
output_b(read_ADC());
}
}
void ADC_init()
{
setup_ADC(ADC_clock_internal);
setup_ADC_ports(AN0);
set_ADC_channel(0);
delay_us(100);
}
- Link download project Click here

Share this

Related Posts

Previous
Next Post »