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 display an INT value on LCD with PSoC?

Status
Not open for further replies.

member_tdh

Member level 5
Joined
Feb 6, 2006
Messages
86
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
2,187
Hi all members!!!

I'm a new PSoC Designer. I'm Writing in C.
I want to display an Int value (or time clock) on the LCD display.
In the lcd toolbox they only talk about displaying a Hex Value.

Help me!!!
Does anyone have some sample code on how to display a Int value?

my code here but not correct, pls help me :

void main()
{
LCD_1_Init();
LCD_1_Start();

while (1)
{
LCD_1_Position(0,0);
LCD_1_PrCString("Time ");
LCD_1_Position(0,5);
LCD_PrintInt((int)cTime.hour);

LCD_1_Position(0,8);
LCD_PrintInt((int)cTime.min);

LCD_1_Position(0,11);
tmp=(WORD)cTime.sec;
LCD_PrintInt(tmp);
}
}

void LCD_PrintInt(WORD val)
{
char str[6];

itoa(str, val, 10);
LCD_1_PrString(str);
}
 

itoa psoc

Please try to run this code. I hope you successed

int hou, mi, se;
void main()
{
LCD_1_Init();
LCD_1_Start();

while (1)
{
LCD_1_Position(0,0);
LCD_1_PrCString("Time ");
LCD_1_Position(0,5);
hou=(int)cTime.hour;
LCD_PrintInt(hou);

LCD_1_Position(0,8);
mi=(int)cTime.min;
LCD_PrintInt(mi);

LCD_1_Position(0,11);
se=(int)cTime.sec;
LCD_PrintInt(se);
}
}

void LCD_PrintInt(int val)
{
char str[6];

itoa(str, val, 10);
LCD_1_PrString(str);
}
 

hex to int + psoc

hi all,
dont forget to include stdlib.h otherwise it will not work
add the following line


#include<stdlib.h>
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top