LCD interfacing problem

Discussion in 'Embedded Systems and Microcontrollers' started by anandan003, Mar 9, 2011.

  1. anandan003

    Thread Starter New Member

    Mar 9, 2011
    1
    0
    Hi friends,


    I am using PIC18f4550 and is interfaced with LCD 16x2. I am printing continuously some ADC values on the LCD. program is working fine, but when the ADC gives 5 digit value first and reduces and comes to a 2 digit value. then the right most digits are not getting cleared up. I don't want to use LCD clear command since it gives a blinking type display.

    problem example

    ADC value :12345----- 5 digit

    ADC value :67345----- 2 digit ( now ADC prints only 67 but 345 is not getting cleared ) pasting part of my code below,

    Thanks in advance,

    Code ( (Unknown Language)):
    1.  
    2.  while(1)
    3.                 {
    4.  
    5.                   Vin = Adc_Read(0);
    6.  
    7.                    //Vin= vin*3.33;
    8.                   // mv = (Vin) >> 10;  (0.0049)
    9.  
    10.                   mv = (Vin * 4004 ) >> 10; // mv = Vin x 5000 / 1024// error correction
    11.                 // mv= mv ;
    12.                   LongToStr(mv,op); // Convert to string in "op"   //
    13.                   j=0;
    14.                       for(i=0;i<=11;i++)
    15.  
    16.                       {
    17.  
    18.                         if(op[i] != ' ') // If a blank
    19.                             {
    20.  
    21.                              lcd[j]=op[i];
    22.                              j++;
    23.  
    24.                            }
    25.                       }
    26.  
    27.  
    28.                    }
    29.  
    30.  
    31.                     // Lcd_Cmd(LCD_RETURN_HOME);
    32.                    //Lcd_Cmd(Lcd_CLEAR);
    33.  
    34.  
    35.                   Lcd_Out(2, 1 ,text2);
    36.  
    37.                   Lcd_Out(2, 4 ,lcd );
    38. [/i][/i]


    Cheers,
    Anand
     
    Last edited by a moderator: Mar 10, 2011
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    991


    Just tack on some extra spaces to the end of your string. If your buffer is only 16 bytes, remember to make it a little bigger.
     
Loading...