A couple of years ago i was learning to use the Ardiuno and started playing around with an Hitachi HD44780 based 16x2 LCD screen. I soon learned that the screen has 8 customizable character slots. I had found a project where someone used those slots to create there own custom characters that could then be used to form large character font using both rows of the screen. I didn't like the look of those characters and couldn't make since of the sketch that person wrote. So i decided i needed to create my own set and use my limited programming skills to create a more user friendly sketch to support my large character font.

In this Instructable i'll show you how i designed my large character font and break down the sketch to make it easier to understand. But first we need to set up the Arduino and LCD. 

Materials Needed:

- Arduino (i used a Nove)
- Hitachi HD44780 based 16x2 LCD
- Breadboard
- 5K Potentiometer
- button or switch
- jumper wires

This shows a revised version of the font.

Here is the finished font

Step 1: Connecting the LCD to the Arduino

First i want to cover how to connect a Hitachi HD44780 based LCD screen to an Arduino. The first thing you need to do is identify Pin 1 on your display and figure out which pins you need. The first image shows a very simple layout for connecting the LCD to your Arduino. Here is the pin Layout for the LCD.
  • Pin 1 - Grd
  • Pin 2 - VCC
  • Pin 3 - Vee (controls screen contrast)
  • Pin 4 - RS (controls where in the LCD's memory your writing too)
  • Pin 5 - RW (controls weather your Reading or Writing to the LCD)
  • Pin 6 - E (enables writing to the register)
  • Pin 7 - D0 (not used)
  • Pin 8 - D1 (not used)
  • Pin 9 - D2 (not used)
  • Pin 10 - D3 (not used)
  • Pin 11 - D4
  • Pin 12 - D5
  • Pin 13 - D6
  • Pin 14 - D7
  • Pin 15 - LED+ (LCD back light)
  • Pin 16 - LED-  (Grd)

My LCD only had 15 pins which is fine since 16 should be tied to ground anyway. As you can see in the picture Vee is tied into a potentiometer. This controls the contrast of the screen. The data pins are the individual bits your writing to or reading from the register.

For the purposes of keeping things simple i wired mine up a bit differently. I like to use ribbon cable whenever possible to keep the clutter of wires down. I makes keeping track of the connections allot easier too. 
  • RS pin to D7
  • E pin to D6
  • D4 pin to D5
  • D5 pin to D4
  • D6 pin to D3
  • D7 pin to D2
  • V0 tied to a pot to control brightness
  • Grd and R/W tied to ground
  • Vcc to +5V
  • pin 15 to push button/switch that is tied to ground for control of back light
With everything connected we can now go over how i created the fonts.

Step 2: Numerical Font Design

It then came time to think about the font design. What kind of segments would i need to create to make a nice and sharp looking large character font for this screen?

I wanted to start simple and get numbers out of the way first. I figured people would be looking for a good large font to use for an Arduino based digital clock or other project. So logically i started by designing the number 8 since all the segments that comprise the 8 can be mixed to create most of the other numbers. This used up only 6 of the custom blocks. But i still needed one more custom block to be able to display a 0, 1 and  7.

The images show the first generation of numbers i produced. A couple of changes where made in the custom blocks to make the numbers look better. I'll show them in a later step.

Step 3: Letter Font Design

After i had created the numbers i moved on to designing letters. I got request from people for letters that are commonly used in Temp, RPM, and Speed displays. So i went ahead and created the full alphabet. To get everything looking right i needed to use the final available custom character block.

The images show the first generation of letters i produced. A couple of changes where made in the custom blocks to make the letters look better. I'll show them in the next step.

Step 4: Refining the Look

My first design for the letters where too rounded for my taste. I then learned how to call up the various predefined characters the LCD is able to display. So i pulled up the Data sheet on the Hitachi HD44780 driver so see the available characters.I noticed the last character is a solid block so i decided to use that in conjunction with the custom characters. I also need the blank character right above the full block. I made a slight adjustment to the custom characters i created and we where ready to build a sketch.

Here is a video of the original characters scrolling across the screen. Some changes have been made since this video was taken.

The code for this will be discussed in the next step.

Step 5: Arduino Sketch

The attached files below are the Arduino sketch that creates the large font and scrolls it across the screen. I've included the sketch in both ide and text format. It has had a couple of updates since the video. Namely the upper left segment of the number 5 has been changed to the full block to help differentiate it from the S. Also the bottom of the 1, 4 and 9 have been changed to the solid box. What follows is a break down of the sketch in hopes of making it easier to understand so you can adapt it for your own project. A more usable but less understandable sketch was created and is give in the next step.

In the code i first want to lay out the basic info about the sketch and the circuit layout.

To help control the LCD we use the LiquidCrystal.h Library. (#include )

We then set the pins on the Arduino that will be used to control the LCD.

Next the sketch sets up 8 arrays which create and store the 8 customized characters that are used to create the large font. Each array is in Binary. The zeros are blank pixels in the character blocks and the ones represent filled in pixels. The abbreviations i used where to help me keep track of where each block would go in reference to building the large number 0. I have labeled the image to give you a better understanding of the segments and there labels.
  • LT= left top
  • UB= upper bar
  • RT= right top
  • LL= lower left
  • LB= lower bar
  • LR= lower right
  • UMB= upper middle bar(upper middle section of the '8')
  • LMB= lower middle bar(lower middle section of the '8')
Next we get into the void setup() of the sketch. Here we need to assign the arrays we just built to the memory slots on the LCD that are available to store custom characters. We assign them a number between zero and seven.

Next we have a set of void customxx() that define the placement of each custom block to create the large font. In each one we first set the cursor on the screen where we want  to start displaying the blocks needed. Lets look at the first one.

void custom0O()
{ // uses segments to build the number 0

  lcd.setCursor(x, 0);  Sets cursor on the first row of the display at location x (x used as a variable that can change so the characters can scroll across the screen)
  lcd.write(8);   places the LT segment
  lcd.write(1);   places the UB segment
  lcd.write(2);   places the RT segment
  lcd.setCursor(x, 1);    Moves cursor to 2nd row
  lcd.write(3);    places the LL segment
  lcd.write(4);    places the LB segment
  lcd.write(5);    Places the LR segment

When we get down to the '5' we start using the solid block which is located at address 255. When we reach the 'A' we use a blank block located at address 254. Its important to note that some Hitachi HD44780 compatible screens will have a blank character at 255 and the solid character will be at 254.

void custom5()
  lcd.setCursor(x, 1);

After we have defined all the letters we lay out the scrolling of the letters. Since the screens buffer isn't large enough we need to break it down into groups that only use 40 columns. Most of the letters only take up 3 columns plus you use 1 column to keep a space between letters. So we lay it out for the first scrolling group to be A, B, C, D, E, F, G, H, I, and J. We throw a small delay on there so you can see the last couple of letters before it clears the screen to move onto the next group. It takes 4 groups to show all the characters on the screen.

Now we reach the main body of the sketch the void loop(). Here we make a call to the first letter group we defined which lays out the letters into the screen's buffer. We then start a For() statement which starts the letters scrolling across the screen. We give it a slight delay after each column shift so the letters are not blurred. When the For() statement is complete we clear the LCD display and have a short delay before moving onto the next group. The sketch will just keep scrolling through all the letter and number groups until you cut the power.

That pretty much covers the sketch. The pictures do a good job of showing the full font. If there is anything i missed or was unclear on please let me know and i'll update this step accordingly.

Step 6: More Efficient Sketch

A few days after i had posted my code on the Arduino forums back in early 2010, Mark S adapted it to be table driven. Since it is table driven it uses no RAM. While it complicates the sketch a bit it is a more efficient way of setting up the large font and goes a long way to making the fonts usable. I don't fully understand it myself but i'm including the code here in text form only.

This was made back in 2008 on IDE 0.8. Things have changed a bit since then so the sketch might not compile. I had to make some adjustments to my original sketch before i could post it here since the Liquid CrystalLibrary had changed a bit since i last used the sketch. 

Here is a link to the thread in the Arduino Forum Archives where i first demonstrated this custom font. There you can read about the evolution that took place in refining the font and the sketch.
<p>Wow! Cool! </p><p>So without doing any real research do you think this could be done with larger screens ei 20x4 or 40x4? I haven't really done any research on this topic but since you could create any combination I would think it's possible unless the screen has some physical limitations. When I get some time I will definitely try this. Thank you for posting!</p>
<p>You would need to check the specs of the particular screen. For the most part the screens should have some programmable character slots to work with. </p>
<p>Hey, great instructable. When I first saw the 2x16 display had 8 programmable characters, I was hoping large fonts or some graphics would be possible, but given the few characters, and only two lines to work with, I just assumed a big font would be impossible. </p><p>But wow, you did an amazing job making it look nice with minimal characters. Kudos. It was inspiring for me to contribute back some improvements. Very creative an minimalistic use of the corners and edge pieces.</p><p>While your letters looked great, in all honesty, your novice (but working!) C code truly made my eyeballs bleed. (Not a snob; I used to do mainframe C compliler language compliance testing, and have worked on Unix utilities for years; so I'm a bit fussy about my C. Code efficiency and compactness is key with me, and are right at home in the Arduino world :) Rather than complain, I'll contribute :)</p><p><strong>Updated Version</strong></p><p>I've reworked your code to add the following:</p><p>- Single nested table for programmable char definitions, rather than 8 global vars<br>- Character design moved into tables, rather than many lines of code. This cuts<br>the sketch size by about half. and makes editing/adding characters easier.<br>- Put character table as a ' '-'_' (ascii 20-5F) table, so other ascii characters could be filled in.<br>- I added Space, period to get character additions rolling. But I got bored, and did a first crack at all the missing characters 0x20-0x5F (mostly punctuation). (A crazy Friday night here, I tell ya, a bit bleary-eyed near the end.) Some of the chars are pretty rough, it'd be great if Michael and/or others could improve upon them.<br>- Used space (hex 20) instead of FE (254 dec) as a blank character, more portable.<br>- Overwrites empty spots in a letter with a space, to help clear overwritten chars.<br>- Added writeString() and writeChar() function. These handle wrapping around the 40-character LCD buffer elegantly for continuous scrolling.<br>- Redid the demo loop, removing global varibables, lists of letters, etc., much simplified and more browseable, IMO.<br>- Call lcd.begin() before programming characters. I would get random dropouts on the prog characters before I did this.</p><p>This should be easier to use, more compact, faster, easier to maintain.</p><p>I'm going to post it to a blog or instructable (with references back here), but wouldn't mind feedback here (specificially from Michael on the glyphs) before finalizing it.</p><p><strong>The sketch</strong></p><p>{{{</p><p>// Based upon the amazing 2-line character set designed by Michael Pilcher<br><br>// Cleaned up for space, efficiency:<br>//<br>// - Single array for programmable characters<br>// - Looped initialization from this table, rather than a series of calls<br>// - Big character composition stored in strings, rather than drawn in functions<br>// One-line per character definition, instead of 11 or so<br>// Makes character tweaking a lot easier<br>// - Characters in an ASCII table, to encourage adding of more characters<br>// - Added the rest of ascii characters 0x20-0x5F (some could use improvement :)<br>// - writeString() function<br>// - Far fewer system calls by writing strings rather than one-byte-per-call<br>// (Note: I changed back to one-byte-per-write, as writing multiple bytes at once<br>// seems to fail to wrap in the LCD's circular display buffer).<br>// - Handles wrapping of LCD circular display buffer :)<br>// - Writes out blank spots in each letter, for cleaner overwriting of previous text<br>// - Uses Space instead of hex 254 blank character; possibly more portable to other displays<br>// - The demo loop is far more elegant (no more x = x + 4, x = x + 4, x = x + 4 :)<br>// - Initialization (begin) called before programming the characters<br>// (Without this, I had inconsistent character programming between runs.)<br><br>// This should run faster, be more stable, provide more characters, take half the space, <br>// and be easier to maintain, than the original.<br>//<br>// Dale Gass<br>// May 10, 2014<br><br>#include &lt;LiquidCrystal.h&gt;<br><br>// Taylor to your pin arrangement<br>// My wiring keeps the 'interruptable' pins 2/3 free for interrupt sue<br>// and pins 10/11 free for SPI communictions/PWM. Plus on the mini Pro,<br>// the six control lines are now sequential along the side of the board,<br>// making wiring easier (using a pin header).<br><br>LiquidCrystal lcd(9, 8, 7, 6, 5, 4);<br><br>/* My circuit:<br> * LCD RS pin to digital pin 9<br> * LCD Enable pin to digital pin 8<br> * LCD D4 pin to digital pin 7<br> * LCD D5 pin to digital pin 6<br> * LCD D6 pin to digital pin 5<br> * LCD D7 pin to digital pin 4<br> * LCD R/W pin to ground<br> * 10K resistor:<br> * ends to +5V and ground - I just grounded pin 3 for full contract<br> * wiper to LCD VO pin (pin 3)<br>*/<br><br>// The standard wiring which prevents int 2/3 and SPI use:<br>// Most common in Arduino LCD samples<br>// LiquidCrystal lcd(12, 11, 5, 4, 3, 2);<br><br>// Eight programmable character definitions<br>byte custom[8][8] = {<br>{ B11111,<br> B11111,<br> B11111,<br> B00000,<br> B00000,<br> B00000,<br> B00000,<br> B00000 },<br> <br>{ B11100,<br> B11110,<br> B11111,<br> B11111,<br> B11111,<br> B11111,<br> B11111,<br> B11111 },<br><br>{ B11111,<br> B11111,<br> B11111,<br> B11111,<br> B11111,<br> B11111,<br> B01111,<br> B00111 },<br><br>{ B00000,<br> B00000,<br> B00000,<br> B00000,<br> B00000,<br> B11111,<br> B11111,<br> B11111 },<br><br>{ B11111,<br> B11111,<br> B11111,<br> B11111,<br> B11111,<br> B11111,<br> B11110,<br> B11100 },<br><br>{ B11111,<br> B11111,<br> B11111,<br> B00000,<br> B00000,<br> B00000,<br> B11111,<br> B11111 },<br><br>{ B11111,<br> B00000,<br> B00000,<br> B00000,<br> B00000,<br> B11111,<br> B11111,<br> B11111 },<br><br>{ B00111,<br> B01111,<br> B11111,<br> B11111,<br> B11111,<br> B11111,<br> B11111,<br> B11111 }<br>};<br><br>// Characters, each with top and bottom half strings<br>// \nnn string encoding is octal, so:<br>// \010 = 8 decimal (8th programmable character)<br>// \024 = 20 decimal (space)<br>// \377 = 255 decimal (black square)<br><br>const char *bigChars[][2] = { <br> {&quot;\024\024\024&quot;, &quot;\024\024\024&quot;}, // Space<br> {&quot;\377&quot;, &quot;\007&quot;}, // !<br> {&quot;\005\005&quot;, &quot;\024\024&quot;}, // &quot;<br> {&quot;\004\377\004\377\004&quot;, &quot;\001\377\001\377\001&quot;}, // #<br> {&quot;\010\377\006&quot;, &quot;\007\377\005&quot;}, // $<br> {&quot;\001\024\004\001&quot;, &quot;\004\001\024\004&quot;}, // %<br> {&quot;\010\006\002\024&quot;, &quot;\003\007\002\004&quot;}, // &amp;<br> {&quot;\005&quot;, &quot;\024&quot;}, // '<br> {&quot;\010\001&quot;, &quot;\003\004&quot;}, // (<br> {&quot;\001\002&quot;, &quot;\004\005&quot;}, // )<br> {&quot;\001\004\004\001&quot;, &quot;\004\001\001\004&quot;}, // *<br> {&quot;\004\377\004&quot;, &quot;\001\377\001&quot;}, // +<br> {&quot;\024&quot;, &quot;\005&quot;}, // ,<br> {&quot;\004\004\004&quot;, &quot;\024\024\024&quot;}, // -<br> {&quot;\024&quot;, &quot;\004&quot;}, // .<br> {&quot;\024\024\004\001&quot;, &quot;\004\001\024\024&quot;}, // /<br> {&quot;\010\001\002&quot;, &quot;\003\004\005&quot;}, // 0<br> {&quot;\001\002\024&quot;, &quot;\024\377\024&quot;}, // 1<br> {&quot;\006\006\002&quot;, &quot;\003\007\007&quot;}, // 2<br> {&quot;\006\006\002&quot;, &quot;\007\007\005&quot;}, // 3<br> {&quot;\003\004\002&quot;, &quot;\024\024\377&quot;}, // 4<br> {&quot;\377\006\006&quot;, &quot;\007\007\005&quot;}, // 5<br> {&quot;\010\006\006&quot;, &quot;\003\007\005&quot;}, // 6<br> {&quot;\001\001\002&quot;, &quot;\024\010\024&quot;}, // 7<br> {&quot;\010\006\002&quot;, &quot;\003\007\005&quot;}, // 8<br> {&quot;\010\006\002&quot;, &quot;\024\024\377&quot;}, // 9<br> {&quot;\004&quot;, &quot;\001&quot;}, // :<br> {&quot;\004&quot;, &quot;\005&quot;}, // ;<br> {&quot;\024\004\001&quot;, &quot;\001\001\004&quot;}, // &lt;<br> {&quot;\004\004\004&quot;, &quot;\001\001\001&quot;}, // =<br> {&quot;\001\004\024&quot;, &quot;\004\001\001&quot;}, // &gt;<br> {&quot;\001\006\002&quot;, &quot;\024\007\024&quot;}, // ?<br> {&quot;\010\006\002&quot;, &quot;\003\004\004&quot;}, // @<br> {&quot;\010\006\002&quot;, &quot;\377\024\377&quot;}, // A<br> {&quot;\377\006\005&quot;, &quot;\377\007\002&quot;}, // B<br> {&quot;\010\001\001&quot;, &quot;\003\004\004&quot;}, // C<br> {&quot;\377\001\002&quot;, &quot;\377\004\005&quot;}, // D<br> {&quot;\377\006\006&quot;, &quot;\377\007\007&quot;}, // E<br> {&quot;\377\006\006&quot;, &quot;\377\024\024&quot;}, // F<br> {&quot;\010\001\001&quot;, &quot;\003\004\002&quot;}, // G<br> {&quot;\377\004\377&quot;, &quot;\377\024\377&quot;}, // H<br> {&quot;\001\377\001&quot;, &quot;\004\377\004&quot;}, // I<br> {&quot;\024\024\377&quot;, &quot;\004\004\005&quot;}, // J<br> {&quot;\377\004\005&quot;, &quot;\377\024\002&quot;}, // K<br> {&quot;\377\024\024&quot;, &quot;\377\004\004&quot;}, // L<br> {&quot;\010\003\005\002&quot;, &quot;\377\024\024\377&quot;}, // M<br> {&quot;\010\002\024\377&quot;, &quot;\377\024\003\005&quot;}, // N<br> {&quot;\010\001\002&quot;, &quot;\003\004\005&quot;}, // 0/0<br> {&quot;\377\006\002&quot;, &quot;\377\024\024&quot;}, // P<br> {&quot;\010\001\002\024&quot;, &quot;\003\004\377\004&quot;}, // Q<br> {&quot;\377\006\002&quot;, &quot;\377\024\002&quot;}, // R<br> {&quot;\010\006\006&quot;, &quot;\007\007\005&quot;}, // S<br> {&quot;\001\377\001&quot;, &quot;\024\377\024&quot;}, // T<br> {&quot;\377\024\377&quot;, &quot;\003\004\005&quot;}, // U<br> {&quot;\003\024\024\005&quot;, &quot;\024\002\010\024&quot;}, // V<br> {&quot;\377\024\024\377&quot;, &quot;\003\010\002\005&quot;}, // W<br> {&quot;\003\004\005&quot;, &quot;\010\024\002&quot;}, // X<br> {&quot;\003\004\005&quot;, &quot;\024\377\024&quot;}, // Y<br> {&quot;\001\006\005&quot;, &quot;\010\007\004&quot;}, // Z<br> {&quot;\377\001&quot;, &quot;\377\004&quot;}, // [<br> {&quot;\001\004\024\024&quot;, &quot;\024\024\001\004&quot;}, // Backslash<br> {&quot;\001\377&quot;, &quot;\004\377&quot;}, // ]<br> {&quot;\010\002&quot;, &quot;\024\024&quot;}, // ^<br> {&quot;\024\024\024&quot;, &quot;\004\004\004&quot;}, // _ <br>};<br><br>int writeBigChar(char ch, int x, int y) {<br> const char *(*blocks)[2] = NULL; // Pointer to an array of two strings (character pointers)<br><br> if (ch &lt; ' ' || ch &gt; '_') // If outside our table range, do nothing<br> return 0;<br> <br> blocks = &amp;bigChars[ch-' ']; // Look up the definition<br><br> for (int half = 0; half &lt;=1; half++) {<br> int t = x; // Write out top or bottom string, byte at a time<br> for (const char *cp = (*blocks)[half]; *cp; cp++) {<br> lcd.setCursor(t, y+half); <br> lcd.write(*cp);<br> t = (t+1) % 40; // Circular scroll buffer of 40 characters, loop back at 40<br> }<br> lcd.setCursor(t, y+half);<br> lcd.write(' '); // Make space between letters, in case overwriting<br> }<br> return strlen((*blocks)[0]); // Return char width<br>}<br><br>void writeBigString(char *str, int x, int y) {<br> char c;<br> while ((c = *str++))<br> x += writeBigChar(c, x, y) + 1;<br>}<br> <br>void setup()<br>{<br> lcd.begin(16, 2);<br> for (int i=0; i&lt;8; i++)<br> lcd.createChar(i+1, custom[i]);<br><br> lcd.clear();<br> writeBigString(&quot;TEST&quot;, 0, 0);<br> delay(2000);<br><br> lcd.clear();<br>}<br><br>int x = 16; // Start writing the character just off the display, and scroll it in<br><br>void loop()<br>{<br> char ch;<br><br> for (ch=' '; ch&lt;='_'; ch++) {<br> int w = writeBigChar(ch, x, 0); // Write big character just off the scren<br> for (int j=0; j&lt;w+1; j++) { // Scroll it in<br> lcd.scrollDisplayLeft();<br> delay(400);<br> }<br> x = (x + w + 1) % 40; // Adjust our new X, handling circular buffer wrap<br> }<br>}</p><p>[/code]</p><p>Let me know any changes or suggestions, in particular with the Glyph design, and I'll get this posted in the next few days.</p><p><strong>Pointers</strong></p><p>The C should be pretty straight forward; I use a few slightly advanced C pointer constructs, like &quot;const char *(*p)[2]&quot; (a variable v, which is a pointer, to an array of two pointers to const chars [an array of two string pointers]. There's an art to understanding and creating C pointers like that; think reading from the inside outworks, working from right to left. Hard to explain, but good to understand to be able to do things efficiently.</p><p>const char *(<strong><em>*p</em></strong>)[2] - 'p' is a pointer to...</p><p>const chart *(*p)<strong>[2]</strong> - an array of two...</p><p><em><strong>const char *</strong></em>(*p)[2] = pointers to const chars (i.e. constant strings)</p><p><a href="http://boredzo.org/pointers/" rel="nofollow">This page</a> has a good rundown of C pointer syntax. Required reading if you're doing any level of Arduino programming beyond the basics.</p><p>(If you are tight for space, you could null out {&quot;&quot;, &quot;&quot;} the definintions for characters that you aren't using in your app. Even better, moving those arrays to PROGMEM (putting them in FLASH instead of prescious RAM) would save a lot, too. Unfortunately all the type-casting required to make PROGMEM arrays obfuscates the code too much. I erred on the side of readability.)</p><p>Thanks again for a creative and inspired font design under tough technical restrictions. Very inspiring.</p><p>Open to any questions, feedback, suggestions.</p><p>-dale</p>
<p>Thanks Dale, yours is easier to understand. (at least, for my limited knowledge of C/C++;)</p><p>x2nie</p>
<p>OMG! Thanks!</p><p>Only took 6 years for someone to finally make this useable for most everyone. This deserves to be an instructable. I'd wait for a suitable contest to come along before posting it. Would make for a good entry. </p><p>When i find some time i'll have to dive into this a bit and see what else i can do. May prove rather useful in a couple of projects i have in mind. </p>
very interesting and wery useful this article... I adapted your sketch for LCD with i2c interface and is ok... my adapted sketch is at http://nicuflorica.blogspot.ro/2013/06/caractere-mari-pe-afisaj-de-2-randuri.html
I just found this. Thanks great work. I am trying to build a large font display for an antenna rotor for a friend who can't see the small analogue needle. So I got my display reading my pot input as 0-360 , but how do I get it to display the large fonts?? <br>Thanks again.
Take a look at step 5 again and see the sketch posted there. Most of the code sets up each letter and number as custom calls. Then the void letters set up which characters i want on the screen. The in the void loop we bring it all together using for statements to have the full set of characters scroll across the screen. <br> <br>Any sketch you create will have to call to the correct void custom to bring up the letter or number you want to display. You will need to take the number you want to display and have a translator function that can break 360 down to 3, 6, and 0 each being stored to there own variable. Then make comparisons between the variable and each number. When a match is found call to that custom character and display it. It's also important to have the correct number of cursor spaces between the first column of the first character and the first column of the next character. Characters like the 'M' and 'W' are wider then the rest. <br> <br>Course all of this makes your code much longer and slower. So if you don't want any kind of delay between moving your pot and getting the readout then this may not be the best option for you.
Ok sounds interesting. ANy ideas on how to do that? (You knew I'd ask...LOL) I looked at converting to a String and you can get character/number positions out of it but I don't know how yet.
Think about a math problem that will be able to get rid of the other digits. May have to be a series of equations that will pull it off. Take the variable and subtract 100. If the variable is greater than 100 add 1 to a tracking variable and loop back to subtract 100 again. If the variable is less than 100 store the tracking variable to the variable for displaying the hundreds and move on to doing a similar equation for the tens and ones. By the end of it all you will have a variable for the hundreds, tens, and ones that match the original number and can make calls to the appropriate character to be displayed.<br> <br> There is likely a much simpler way of doing it but that is the first thing to come to mind.<br> <br> Quick code of the hundreds breakdown:<br> <em>int analog = ??? //value read from the pot input<br> int track = 0 //tracking variable<br> int hund = 0 //hundreds place<br> int ten = 0 //tens place<br> int one = 0 //ones place<br> int comp = analog //for storing analog variable after numbers have been subtracted<br> <br> viod breakhund()<br> if comp &gt;100<br> comp = analog-100<br> track++<br> breakhun<br> end<br> <br> if comp &lt; 100<br> hund = track<br> track = 0<br> breakten<br> <br> void breakten()</em><br> <br> <br> Of course&nbsp;punctuation&nbsp;is missing but that should give you an idea. The tens and ones will follow in the same&nbsp;fashion.&nbsp;You can pretty much copy and past the same code just drop a zero each time.&nbsp;
Thanks. I finally got some time and I got it to work as you indicated. (Or very close) so I have it displaying 0-360 like I need. I can't get it to clear the numbers properly, such as when you change from 0 to 1 it still displays bits of the 0 along with the 1. I tried using the lcd.write(&quot; &quot;); but it didn't work, I put it into the spot where it prints characters in the function that is called to print a custom character. I also tried the lcd.clear but it is either too fast to see the characters or too slow and they blink. <br>I thought I'd pick your brain a bit to see if you have an idea. <br>Thanks for your help so far!! <br> <br>Here is the code.. <br> <br>// These constants won't change. They're used to give names <br>// to the pins used: <br>const int analogInPin = A0; // Analog input pin that the potentiometer is attached to <br> <br>int sensorValue = 0; // value read from the pot <br>int outputValue = 0; // value output to the PWM (analog out) <br>//char outputValueChar[5]; <br>int hundreds; <br>int tens; <br>int ones; <br>#include <br>LiquidCrystal lcd(12, 11, 5, 4, 3, 2); <br> <br> <br>// the 8 arrays that form each segment of the custom numbers <br>byte LT[8] = <br>{ <br> B00111, <br> B01111, <br> B11111, <br> B11111, <br> B11111, <br> B11111, <br> B11111, <br> B11111 <br>}; <br>byte UB[8] = <br>{ <br> B11111, <br> B11111, <br> B11111, <br> B00000, <br> B00000, <br> B00000, <br> B00000, <br> B00000 <br>}; <br>byte RT[8] = <br>{ <br> B11100, <br> B11110, <br> B11111, <br> B11111, <br> B11111, <br> B11111, <br> B11111, <br> B11111 <br>}; <br>byte LL[8] = <br>{ <br> B11111, <br> B11111, <br> B11111, <br> B11111, <br> B11111, <br> B11111, <br> B01111, <br> B00111 <br>}; <br>byte LB[8] = <br>{ <br> B00000, <br> B00000, <br> B00000, <br> B00000, <br> B00000, <br> B11111, <br> B11111, <br> B11111 <br>}; <br>byte LR[8] = <br>{ <br> B11111, <br> B11111, <br> B11111, <br> B11111, <br> B11111, <br> B11111, <br> B11110, <br> B11100 <br>}; <br>byte UMB[8] = <br>{ <br> B11111, <br> B11111, <br> B11111, <br> B00000, <br> B00000, <br> B00000, <br> B11111, <br> B11111 <br>}; <br>byte LMB[8] = <br>{ <br> B11111, <br> B00000, <br> B00000, <br> B00000, <br> B00000, <br> B11111, <br> B11111, <br> B11111 <br>}; <br> <br>// loop counter <br>int x = 0; <br> <br> <br>void setup() <br>{ <br> Serial.begin(9600); <br> // assignes each segment a write number <br> lcd.createChar(0,LT); <br> lcd.createChar(1,UB); <br> lcd.createChar(2,RT); <br> lcd.createChar(3,LL); <br> lcd.createChar(4,LB); <br> lcd.createChar(5,LR); <br> lcd.createChar(6,UMB); <br> lcd.createChar(7,LMB); <br> <br> <br> // sets the LCD's rows and colums: <br> lcd.begin(16, 2); <br> <br>} <br> <br>void custom0() <br>{ // uses segments to build the number 0 <br> lcd.setCursor(x, 0); // set cursor to column 0, line 0 (first row) <br> lcd.write((byte)0); // call each segment to create <br> lcd.write(1); // top half of the number <br> lcd.write(2); <br> lcd.setCursor(x, 1); // set cursor to colum 0, line 1 (second row) <br> lcd.write(3); // call each segment to create <br> lcd.write(4); // bottom half of the number <br> lcd.write(5); <br>} <br> <br>void custom1() <br>{ <br> lcd.setCursor(x,0); <br> lcd.write(1); <br> lcd.write(2); <br> lcd.setCursor(x+1,1); <br> lcd.write(5); <br>} <br> <br>void custom2() <br>{ <br> lcd.setCursor(x,0); <br> lcd.write(6); <br> lcd.write(6); <br> lcd.write(2); <br> lcd.setCursor(x, 1); <br> lcd.write(3); <br> lcd.write(7); <br> lcd.write(7); <br>} <br> <br>void custom3() <br>{ <br> lcd.setCursor(x,0); <br> lcd.write(6); <br> lcd.write(6); <br> lcd.write(2); <br> lcd.setCursor(x, 1); <br> lcd.write(7); <br> lcd.write(7); <br> lcd.write(5); <br>} <br> <br>void custom4() <br>{ <br> lcd.setCursor(x,0); <br> lcd.write(3); <br> lcd.write(4); <br> lcd.write(2); <br> lcd.setCursor(x+2, 1); <br> lcd.write(5); <br>} <br> <br>void custom5() <br>{ <br> lcd.setCursor(x,0); <br> lcd.write((byte)0); <br> lcd.write(6); <br> lcd.write(6); <br> lcd.setCursor(x, 1); <br> lcd.write(7); <br> lcd.write(7); <br> lcd.write(5); <br>} <br> <br>void custom6() <br>{ <br> lcd.setCursor(x,0); <br> lcd.write((byte)0); <br> lcd.write(6); <br> lcd.write(6); <br> lcd.setCursor(x, 1); <br> lcd.write(3); <br> lcd.write(7); <br> lcd.write(5); <br>} <br> <br>void custom7() <br>{ <br> lcd.setCursor(x,0); <br> lcd.write(1); <br> lcd.write(1); <br> lcd.write(2); <br> lcd.setCursor(x+1, 1); <br> lcd.write((byte)0); <br>} <br> <br>void custom8() <br>{ <br> lcd.setCursor(x,0); <br> lcd.write((byte)0); <br> lcd.write(6); <br> lcd.write(2); <br> lcd.setCursor(x, 1); <br> lcd.write(3); <br> lcd.write(7); <br> lcd.write(5); <br>} <br> <br>void custom9() <br>{ <br> lcd.setCursor(x,0); <br> lcd.write((byte)0); <br> lcd.write(6); <br> lcd.write(2); <br> lcd.setCursor(x+2, 1); <br> lcd.write(5); <br>} <br> <br> <br> <br> <br> <br>void loop() { <br> // read the analog in value: <br> sensorValue = analogRead(analogInPin); <br> // map it to the range of the analog out: <br> outputValue = map(sensorValue, 0, 1023, 0, 360); <br> <br> // print the results to the serial monitor: <br> Serial.print(&quot;sensor = &quot; ); <br> Serial.print(sensorValue); <br> Serial.print(&quot;\t output = &quot;); <br> Serial.println(outputValue); <br> <br> String stringOne = String(outputValue); <br> // prints the value of outputValue <br> //Serial.print(&quot;Output value string is &quot;); <br> //Serial.println(stringOne); <br> x=0; <br> hundreds = outputValue /100; <br> //Serial.print(hundreds); <br> delay(500); <br> <br> switch (hundreds) { <br> case 3: <br> custom3(); <br> break; <br> <br> case 2: <br> <br> custom2(); <br> break; <br> <br> case 1: <br> <br> custom1(); <br> break; <br> <br> case 0: <br> <br> custom0(); <br> break; <br> <br> } <br> <br> tens=outputValue /10; <br> tens=tens%10; <br> //Serial.println(tens); <br> <br> switch (tens) { <br> case 9: <br> x=x+3; <br> <br> custom9(); <br> break; <br> <br> case 8: <br> x=x+3; <br> <br> custom8(); <br> break; <br> <br> case 7: <br> x=x+2; <br> <br> custom7(); <br> break; <br> <br> case 6: <br> x=x+3; <br> <br> custom6(); <br> break; <br> <br> case 5: <br> x=x+3; <br> <br> custom5(); <br> break; <br> <br> case 4: <br> x=x+3; <br> <br> custom4(); <br> break; <br> <br> case 3: <br> x=x+3; <br> <br> custom3(); <br> break; <br> <br> case 2: <br> x=x+3; <br> <br> custom2(); <br> break; <br> <br> case 1: <br> x=x+3; <br> <br> custom1(); <br> break; <br> <br> if (outputValue&lt;10) <br> { <br> //case 0: <br> x=x+3; <br> <br> custom0(); <br> break; <br> } <br> <br> case 0: <br> x=x+3; <br> <br> custom0(); <br> break; <br> } <br> <br> ones=outputValue%10; <br> //ones=ones%100; <br> // Serial.println(ones); <br> <br> switch (ones) { <br> case 9: <br> x=x+3; <br> <br> custom9(); <br> break; <br> <br> case 8: <br> x=x+3; <br> <br> custom8(); <br> break; <br> <br> case 7: <br> x=x+3; <br> <br> custom7(); <br> break; <br> <br> case 6: <br> x=x+3; <br> <br> custom6(); <br> break; <br> <br> case 5: <br> x=x+3; <br> <br> custom5(); <br> break; <br> <br> case 4: <br> x=x+3; <br> <br> custom4(); <br> break; <br> <br> case 3: <br> x=x+3; <br> <br> custom3(); <br> break; <br> <br> case 2: <br> x=x+3; <br> <br> custom2(); <br> break; <br> <br> case 1: <br> x=x+3; <br> <br> custom1(); <br> break; <br> <br> case 0: <br> x=x+3; <br> <br> custom0(); <br> break; <br> <br> } <br> /* <br> delay(500); <br> lcd.setCursor(0,1); <br> lcd.print(outputValue); */ <br> //delay(300); <br> //lcd.clear(); <br> <br> //if (outputValue &lt; 100) <br> // { <br> // x=0; <br> // lcd.print(&quot; &quot;); <br> // } <br> <br> // wait 2 milliseconds before the next loop <br> // for the analog-to-digital converter to settle <br> // after the last reading: <br> //delay(10); <br> <br> <br>}
Put the lcd.clear before the set cursor and drop the delay before the set cursor. Keep and play around with the delay after the lcd.print. Should smooth things out for you a bit. <br> <br>There is already a delay with the processing leading up to the print update. So that combined with the delay after the print leaves the display showing strong. Then it get through the processing and clears the screen a millisecond before it prints again causing an imperceptible update.
Looks like I got it, I found a lcd.clear rate that works and no (&quot; &quot;) needed. I also &quot;fixed&quot; what I didn't care for with the 1 digit. So it looks all good now. All with your help though!! Thank you very much!!!
Please, what's the name of that the schematic 3d generator software?
The image above was created with http://fritzing.org
Thanks for the run down man; I have two 16x2 IM161 Microtivity units I'm playing with currently on various Arduino projects.

About This Instructable




Bio: I'm a jack of all trades and a master of none. I like to tweak, mod and improvise whenever possible!
More by mpilchfamily:Universal USB Power Supply Kit FM Bug Detector Kit FM Listening Bug 
Add instructable to: