Hello
I have a problem with my 16X2 LCD. I am trying to display a simple string of characters.
For the first 2 seconds of the program the display should display 'Voltmeter' then go into a continuous loop
displaying mV = what ever voltage .
My problem is my LCD only displays the first character of the sting.
.i.e 'V' rather than 'Voltmeter'. and 'm' rather than 'mV'. However i can display the voltage reading just fine.
The display looks like this ' m 5000'
Rather than ' mV = 5000'
I am using Mikroc on a PIC18f45k22. I am uploading the HEX file from MPLAB IDE via PICKIT3.
Here is my code:
Thanks Lester
[code
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;
void main() {
unsigned long Vin, mV;
unsigned char op[12];
unsigned char i, j, lcd[5];
char *str;
ANSELB = 0;
ANSELA = 1;
TRISB = 0;
TRISA = 1;
Lcd_Init();
Delay_ms(1);
Lcd_cmd(_LCD_CLEAR);
Delay_ms(1);
Lcd_cmd(_LCD_CURSOR_OFF);
Delay_ms(1);
Lcd_Out (1,1,"VOLTMETER");
Delay_ms(2000);
ADCON1 = 0x80;
for(;;)
{
Lcd_cmd(_LCD_CLEAR);
Vin = Adc_Read(0);
Lcd_Out(1,1,"mV = ");
mV = (Vin * 5000) >> 10;
LongToStr(mV,op);
str = Ltrim(op);
Lcd_Out(1,6,str);
Delay_ms(1000);
}
}
]