Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Disply multiple int on 16X2 lcd

Status
Not open for further replies.

skmdmasud

Member
Hi.
I am trying to display 4 different int variables in my lcd using just single display command to
save program memory.

The lcd library that i am using accepts the following to display int

LCDWriteIntXY(X,Y,VALUE,UNIT);
LCDWriteIntXY(2,0,a,4);
or
LCDWriteStringXY(0,1,"My Values");

I have four different int variable e.g. a,b,c and d.
a=1;
b=2;
c=999;
d=999;

I want to display this as following
| 1-2-999-999 |

How do i make it into a single char or string and display it.

Regards.
 
I write my own routines for ASCII conversion

C:
void printFloat(char * flt, long number, char digits)
	{
	if(number < 0)
		{
		number = ABS(number);
		}
	if(digits == 2)
		{
		flt[0] = number / 1000 + 48;
		if(flt[0] == 48) flt[0] = 0x20;
		flt[1] = ((number % 1000) / 100)+ 48;
		flt[2] = 46;
		flt[3] = ((number % 100) / 10)+ 48;
		flt[4] = (number % 10) + 48;
		flt[5] = 0;
		}
	else
		{
		flt[0] = number / 100 + 48;
		if(flt[0] == 48) flt[0] = 0x20;
		flt[1] = ((number % 100) / 10)+ 48;
		flt[2] = 46;
		flt[3] = (number % 10) + 48;
		flt[4] = 0;
		}
	}

You could tune this to do what you need it to do...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top