# How to get voltage on lcd (line 1) to be proportional to custom lcd user generated Char (line2)

#### HappyC4mper

Joined Oct 13, 2017
57

Last edited:

#### HappyC4mper

Joined Oct 13, 2017
57
edit- removed pictures

Last edited:

#### HappyC4mper

Joined Oct 13, 2017
57
I guess I can do it like this? Since there are 16 blocks in LCD line 2 and my max voltage is 3.3V. I can do 3.3/16=0.2. So for every block is worth 0.2.
as shown below in my picture.
But, im not sure how to make it into a custom character or there must be an easier way to do this?

#### Attachments

• 130.8 KB Views: 2

#### AlbertHall

Joined Jun 4, 2014
9,282
But when I decrease the votlage, the custom character does not.
You will need to overwrite the unwanted blocks with spaces.

#### HappyC4mper

Joined Oct 13, 2017
57
You will need to overwrite the unwanted blocks with spaces.
I kind of did that with this code
Code:
void ASignal (float q)   //analague signal.
{
float divider = 255;
int sum = q/divider;

cmdLCD(LCD_LINE2);
for(int i = 0; i<sum; i++)
if(i==sum)
{
putLCD('  ');
}
else putLCD(0xFF);

I tried it like this https://imgur.com/a/nXq3wOs
But I feel like there's an easier way.

#### AlbertHall

Joined Jun 4, 2014
9,282
I kind of did that with this code
No you didn't.
The for loop will print the necessary number of blocks and then exit. Within that loop 'i' will never equal 'sum'.
After the for loop ends you need another for loop which runs from 'sum' to 16 and writes spaces.

That would be the simple way to do it.
You could make it more 'intelligent' by keeping track of the last number of blocks and then adding or deleting blocks as necessary but that's more difficult to write.

#### HappyC4mper

Joined Oct 13, 2017
57
No you didn't.
The for loop will print the necessary number of blocks and then exit. Within that loop 'i' will never equal 'sum'.
After the for loop ends you need another for loop which runs from 'sum' to 16 and writes spaces.

That would be the simple way to do it.
You could make it more 'intelligent' by keeping track of the last number of blocks and then adding or deleting blocks as necessary but that's more difficult to write.
Ah i see.
Sorry if it's a hassle, but do you mind showing me an example of the more intelligent way? cheers.