Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to use IntToStr() or sprintf() in mikroc for pic to print value in lcd

Status
Not open for further replies.

mahm150

Full Member level 1
Joined
Dec 14, 2010
Messages
98
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Cairo, Egypt, Egypt
Activity points
2,001
i use 4bit custom lcd in mikroc with pic18f4520 it work ok with text but i cant send value of variable in lcd
i try to use
Code:
IntToStr(time4_lectures, txt);
or
Code:
sprintf(buffer,"%d",time4_lectures);
but it not work ok
///////////////////////////////////////the function in mikroc
Code:
void Lcd_Custom_Out_Cp(char *text);
Prints text on LCD at current cursor position. Both string variables and literals can be passed as text.
///////////////////////////////////////////////
Code:
void Lcd_Custom_Chr_Cp(char character);
Prints character on LCD at current cursor position. Both variables and literals can be passed as character
/////////////////////////////////////////////////////
this part of my code

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
void periode_of_lecture(void)
{
 int prev_time4_lectures,time4_lectures;
 unsigned char x;
 prev_time4_lectures= Eeprom_Read(time4_lectures_address);
 time4_lectures=prev_time4_lectures;
 Lcd_Custom_Out(1, 1,"lecture time=");
 //sprintf(buffer,"%d",time4_lectures);
 //IntToStr(time4_lectures, txt);
 Lcd_Custom_Out_Cp(buffer);
     while(CANCEL==1)
     {
        if(UP==0)
             {
                while(UP==0);
                 x= time4_lectures+5;
               //IntToStr(time4_lectures, txt);
              // sprintf(buffer,"%d",time4_lectures);
               Lcd_Custom_Out_Cp(48+x);// i use this line as  examples in mikroc
             //  Lcd_Custom_Chr(1, 14,txt);
             }
         if(DOWN==0)
             {
               while(DOWN==0);
                x=time4_lectures-5;
           //     sprintf(buffer,"%d",time4_lectures);
               Lcd_Custom_Out_Cp(48+x);
              // IntToStr(time4_lectures, txt);
              // Lcd_Custom_Chr(1, 14,txt);
             }
    }
}

 
Last edited by a moderator:

Where is your buffer table declared?

I generally use this code
sprintf(buffer,"%d",time4_lectures);
lcd_write_string(buffer);
with success under C18 and C30, lcd functions i have written myself.

Can you actually print anything (like lcd_write_string("blablabla"); )?
 

i use the LCD libraries in mikroc , i define buffer as char buffer[20] in the first of program
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top