jean12
Advanced Member level 2
- Joined
- Aug 27, 2013
- Messages
- 529
- Helped
- 5
- Reputation
- 12
- Reaction score
- 6
- Trophy points
- 18
- Activity points
- 5,497
Hello there ,I have a problem;I want to interface an LCD to PIC16F876A for digital voltmeter 0-30VDC.
can you help me to see what's wrong with the below codes?
Thanks
can you help me to see what's wrong with the below codes?
PHP:
#include "16f876a.h" use portc for output
#device adc=10
#fuses HS,NOWDT,NOLVP,NOCPD
#use delay(clock=4M)
#include "lcd.c"
int value;
float value1,value2;
char *volt = "00.00";
void main()
{
set_tris_a(0xff);
set_tris_d(0x00);
set_tris_c(0x00);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(ALL_ANALOG);
set_adc_channel(0);
setup_vref(FALSE);
lcd_init();
lcd_gotoxy(1,1);
while(1)
{
delay_us(20);
read_adc(adc_start_only);
delay_us(100);
value=read_adc(adc_read_only);
value1=value*500*6/1023;
value2=value1;
volt[0] = value2/1000 + 48;
volt[1] = value2/100)%10 + 48;
volt[3] = (value2/10)%10 + 48;
printf(lcd_putc,"\f%c",volt);
delay_ms(100);
printf(lcd_putc,2,5,volt);
/*
delay_ms(150);
printf(lcd_putc,"\f%.3f",value2);
delay_ms(500);
*/
}
}