sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
char Txt[15];
void main()
{
unsigned int adc_value;
unsigned int d;
PORTA = 0b00000000;
TRISA = 0xFF;
ADC_Init();
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
while(1)
{
adc_value = ADC_read(0);
adc_value = adc_value>>2;
//d = map(adc_value, 0, 1023, 0, 255);
IntToStr(adc_value,Txt); // Convert voltage to string
Lcd_Out(2,1,"d =");
Lcd_Out(2,5,Txt);
Delay_ms(300);
}
}
yes!! this works.But i wanted to do it using Function call.