chào mọi ngừoi mình viết chương trình hiển thị adc ra lcd.nhung ko bít sai chỗ nào mà chưa hiển thị lên được mong mọi người chỉ giáo
#include <16F877.h>
#include"F:\nghiencuu2007\picc\DEFS_16F877a.h"
#fuses HS,NOWDT,NOPROTECT,NOLVP
#device 16F877*=16 ADC=8
#use delay(clock=8M,oscillator)
#use fast_io(b)
#use fast_io(d)
#byte portb = 0x06
#byte portd = 0x08
#define RS RD0
#define RW RD1
#define E RD2
#define lcd portb
//tao ham lenh ghi
void commwrite(){
//lcd=x;
RS = 0;
RW = 0;
E = 1;
E = 0;
delay_ms(50);
}
//tao ham gui du lieu
void datawrite(){
//lcd=x;
RS = 1;
RW = 0;
E = 1;
E = 0;
delay_ms(100);
}
int8 adc;
void main()
{
delay_ms(100); //tao ham tre de khoi dong LCD
lcd = 0x38;
commwrite();
LCD = 0x0c; //bat hien thi,tat con tro
commwrite();
lcd = 0x01;
commwrite();
lcd=0x06;
commwrite();
LCD = 0x85; //xuong dau dong
commwrite();
setup_adc(adc_clock_internal);
setup_adc_ports(ALL_ANALOG );
set_tris_b(0);
set_tris_d(0);
//output_b(0x00);
//output_d(0x00);
while(true)
{
set_adc_channel(0);
delay_ms(10);
adc=read_adc();
//lcd=adc;
printf(datawrite,adc);
delay_ms(10);
#include"F:\nghiencuu2007\picc\DEFS_16F877a.h"
#fuses HS,NOWDT,NOPROTECT,NOLVP
#device 16F877*=16 ADC=8
#use delay(clock=8M,oscillator)
#use fast_io(b)
#use fast_io(d)
#byte portb = 0x06
#byte portd = 0x08
#define RS RD0
#define RW RD1
#define E RD2
#define lcd portb
//tao ham lenh ghi
void commwrite(){
//lcd=x;
RS = 0;
RW = 0;
E = 1;
E = 0;
delay_ms(50);
}
//tao ham gui du lieu
void datawrite(){
//lcd=x;
RS = 1;
RW = 0;
E = 1;
E = 0;
delay_ms(100);
}
int8 adc;
void main()
{
delay_ms(100); //tao ham tre de khoi dong LCD
lcd = 0x38;
commwrite();
LCD = 0x0c; //bat hien thi,tat con tro
commwrite();
lcd = 0x01;
commwrite();
lcd=0x06;
commwrite();
LCD = 0x85; //xuong dau dong
commwrite();
setup_adc(adc_clock_internal);
setup_adc_ports(ALL_ANALOG );
set_tris_b(0);
set_tris_d(0);
//output_b(0x00);
//output_d(0x00);
while(true)
{
set_adc_channel(0);
delay_ms(10);
adc=read_adc();
//lcd=adc;
printf(datawrite,adc);
delay_ms(10);
Comment