كود:
sbit LCD_RS at Rd2_bit;
sbit LCD_EN at Rd3_bit;
sbit LCD_D4 at Rd4_bit;
sbit LCD_D5 at Rd5_bit;
sbit LCD_D6 at Rd6_bit;
sbit LCD_D7 at Rd7_bit;
sbit LCD_RS_Direction at TRISd2_bit;
sbit LCD_EN_Direction at TRISd3_bit;
sbit LCD_D4_Direction at TRISd4_bit;
sbit LCD_D5_Direction at TRISd5_bit;
sbit LCD_D6_Direction at TRISd6_bit;
sbit LCD_D7_Direction at TRISd7_bit;
float v=0,v1=0;
char i[15];
void main()
{
lcd_init();
lcd_cmd(_LCD_CURSOR_OFF); Lcd_Cmd(_Lcd_Clear);
lcd_out(2,5,"Volt");
while(1)
{
v=adc_read(0);
v1=v*25/1023;
floattostr(v1,i);
lcd_out(1,5,i);
}
}
بالامكان وضع سلكتر سويتش من اجل زيادة مدى القياس و الحفاظ على نفس الدقة ...