Pic16f877a lcd problem

Discussion in 'Embedded Systems and Microcontrollers' started by miloboy, Nov 18, 2010.

  1. miloboy

    Thread Starter New Member

    Jun 1, 2010
    19
    0
    i use ccs compiler , on the driver i saw LCD.c but i failed to use to display a float data or int data from my code .. anyone can help ?

    Code ( (Unknown Language)):
    1.  
    2. [FONT=Calibri]#include <16F877.h>
    3. #device ADC=12
    4. #fuses  HS,NOWDT,NOPROTECT,NOLVP
    5. #use delay(clock=20000000)[/FONT]
    6.  
    7.  [FONT=Calibri]#include <LCD.c>[/FONT]
    8.  
    9.  [FONT=Calibri]void main()
    10. {
    11.      int  chan ;
    12.     float    analin[8], disvolts[8], current;[/FONT]
    13.  
    14.  [FONT=Calibri] setup_adc(ADC_CLOCK_INTERNAL);
    15.  setup_adc_ports(ALL_ANALOG);[/FONT]
    16.  
    17.  [FONT=Calibri]    while(1)
    18.     {
    19.      for(chan=0;chan<8;chan++)
    20.      { delay_ms(50);
    21.              set_adc_channel(chan);
    22.               analin[chan] =  read_adc();
    23.             disvolts[chan] =  (analin[chan])/204.6;
    24.            current = (disvolts[chan]*240);[/FONT]
    25.  [FONT=Calibri]
    26.    lcd_init();[/FONT]
    27.  
    28.  [FONT=Calibri]   lcd_putc("\f  hello");
    29.    lcd_putc(current);[/FONT]
    30.  
    31.  
    32.  
    33. [FONT=Calibri]
    34.      }
    35.     }
    36. }
    37.  
    38. [/FONT]




    what shud I do if I need to display a float or int ? please help

     
    Last edited by a moderator: Nov 18, 2010
  2. cheezewizz

    Active Member

    Apr 16, 2009
    82
    10
    convert it to a char* first...
     
  3. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    Something like this:

    Code ( (Unknown Language)):
    1.  
    2. char string[20];
    3.  
    4. sprintf(string,(const far rom char*)"Panel    %2d.%02dV                ",(int)fPanelVolts ,(int)((fPanelVolts - (int)fPanelVolts) *100));
    5.  
    6.  
     
Loading...