1

I'm working on a project where I'm trying to display the level of a filled tank through ultrasonic, then displaying it on a 16x2 LCD. I'm trying to do it through the whole LCD Pixels, such that when the tank level is full, the first 5 pixels are activated (as what happens when you connect the LCD initially without having any code for it, the whole pixels are turned on, giving 16x2 white rectangles, as shown in the picture below). Is there a way to activate an entire pixel on the LCD?

enter image description here

  • You can define your own characters to display. Is that what you want? – Majenko Jun 7 '20 at 16:05
  • @Majenko Nope. My issue is not to display characters. However, I want to display the white rectangles, as shown in the picture. Is there a code to activate the entire rectangle pixel? – Zelreedy Jun 7 '20 at 16:07
  • 1
    You can define your own characters. Make a character that has all the pixels you want set. – Majenko Jun 7 '20 at 16:09
  • @Majenko Oh I see. I assumed there was an easier way, since it just activates the entire rectangular pixel. Thanks for your help! – Zelreedy Jun 7 '20 at 16:23
  • 1
    that picture shows all of the pixels in the first line activated ... there are no in-between pixels – jsotola Jun 7 '20 at 16:37
2

The LCD is made up from 32 characters each is 5x7 pixels in size, with a 1 pixel gap between each character.

You can never put anything in the gap between the characters, as there is just nothing there.

But what you can do is define your own characters to fit within the 5x7 pixel rectangles.

Some variants of the HD44780 have character 255 as a solid block, but not all (it depends on what language the ROM is). If you have one that has that character you can just print it with lcd.print("\xff") or lcd.write(255). If it doesn't it will print ÿ instead. In that case you will have to define your own character.

One benefit of defining your own characters is that you could then do partial blocks to give you a higher resolution. Here's an example:

enter image description here

You can find that example and the code that goes with it here.

0

The LCDs like the one you picture display characters. That is all they do. You can't address the pixels in the display.

And as a point of clarification, you are talking about the 5 pixel by 7 pixel character blocks on the display as if a character is a pixel. It's not. A character block consists of 5 x 7 pixels.

Some versions may have a pre-defined solid block character, as Majenko said in their answer. You could print as many of those solid blocks as you want.

You could also define a single custom character that displays a solid block and print as many of those as you want.

As a third option (again from Majenko's excellent answer) you could define 5 different custom characters, each with a different number of columns of pixels filled in. You could then write code that displayed solid blocks for all but the last character, and then one of the 5 partly filled custom characters, and get a finer resolution of simulated bar graph.

All that said, remember, the LCD display can only display 5x7 blocks with blank space between. The LCD is built without any pixels between the characters, so there will always be blank spaces.

There are other pixel displays you could use. (I've seen OLED displays where you can control every character individually.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.