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.
Here is the finished font
Remove these ads by
Signing UpStep 1: Connecting the LCD to the Arduino
- 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











































Visit Our Store »
Go Pro Today »




Thanks again.
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.
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.
There is likely a much simpler way of doing it but that is the first thing to come to mind.
Quick code of the hundreds breakdown:
int analog = ??? //value read from the pot input
int track = 0 //tracking variable
int hund = 0 //hundreds place
int ten = 0 //tens place
int one = 0 //ones place
int comp = analog //for storing analog variable after numbers have been subtracted
viod breakhund()
if comp >100
comp = analog-100
track++
breakhun
end
if comp < 100
hund = track
track = 0
breakten
void breakten()
Of course punctuation is missing but that should give you an idea. The tens and ones will follow in the same fashion. You can pretty much copy and past the same code just drop a zero each time.
I thought I'd pick your brain a bit to see if you have an idea.
Thanks for your help so far!!
Here is the code..
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
//char outputValueChar[5];
int hundreds;
int tens;
int ones;
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// the 8 arrays that form each segment of the custom numbers
byte LT[8] =
{
B00111,
B01111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
};
byte UB[8] =
{
B11111,
B11111,
B11111,
B00000,
B00000,
B00000,
B00000,
B00000
};
byte RT[8] =
{
B11100,
B11110,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
};
byte LL[8] =
{
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B01111,
B00111
};
byte LB[8] =
{
B00000,
B00000,
B00000,
B00000,
B00000,
B11111,
B11111,
B11111
};
byte LR[8] =
{
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11110,
B11100
};
byte UMB[8] =
{
B11111,
B11111,
B11111,
B00000,
B00000,
B00000,
B11111,
B11111
};
byte LMB[8] =
{
B11111,
B00000,
B00000,
B00000,
B00000,
B11111,
B11111,
B11111
};
// loop counter
int x = 0;
void setup()
{
Serial.begin(9600);
// assignes each segment a write number
lcd.createChar(0,LT);
lcd.createChar(1,UB);
lcd.createChar(2,RT);
lcd.createChar(3,LL);
lcd.createChar(4,LB);
lcd.createChar(5,LR);
lcd.createChar(6,UMB);
lcd.createChar(7,LMB);
// sets the LCD's rows and colums:
lcd.begin(16, 2);
}
void custom0()
{ // uses segments to build the number 0
lcd.setCursor(x, 0); // set cursor to column 0, line 0 (first row)
lcd.write((byte)0); // call each segment to create
lcd.write(1); // top half of the number
lcd.write(2);
lcd.setCursor(x, 1); // set cursor to colum 0, line 1 (second row)
lcd.write(3); // call each segment to create
lcd.write(4); // bottom half of the number
lcd.write(5);
}
void custom1()
{
lcd.setCursor(x,0);
lcd.write(1);
lcd.write(2);
lcd.setCursor(x+1,1);
lcd.write(5);
}
void custom2()
{
lcd.setCursor(x,0);
lcd.write(6);
lcd.write(6);
lcd.write(2);
lcd.setCursor(x, 1);
lcd.write(3);
lcd.write(7);
lcd.write(7);
}
void custom3()
{
lcd.setCursor(x,0);
lcd.write(6);
lcd.write(6);
lcd.write(2);
lcd.setCursor(x, 1);
lcd.write(7);
lcd.write(7);
lcd.write(5);
}
void custom4()
{
lcd.setCursor(x,0);
lcd.write(3);
lcd.write(4);
lcd.write(2);
lcd.setCursor(x+2, 1);
lcd.write(5);
}
void custom5()
{
lcd.setCursor(x,0);
lcd.write((byte)0);
lcd.write(6);
lcd.write(6);
lcd.setCursor(x, 1);
lcd.write(7);
lcd.write(7);
lcd.write(5);
}
void custom6()
{
lcd.setCursor(x,0);
lcd.write((byte)0);
lcd.write(6);
lcd.write(6);
lcd.setCursor(x, 1);
lcd.write(3);
lcd.write(7);
lcd.write(5);
}
void custom7()
{
lcd.setCursor(x,0);
lcd.write(1);
lcd.write(1);
lcd.write(2);
lcd.setCursor(x+1, 1);
lcd.write((byte)0);
}
void custom8()
{
lcd.setCursor(x,0);
lcd.write((byte)0);
lcd.write(6);
lcd.write(2);
lcd.setCursor(x, 1);
lcd.write(3);
lcd.write(7);
lcd.write(5);
}
void custom9()
{
lcd.setCursor(x,0);
lcd.write((byte)0);
lcd.write(6);
lcd.write(2);
lcd.setCursor(x+2, 1);
lcd.write(5);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 360);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
String stringOne = String(outputValue);
// prints the value of outputValue
//Serial.print("Output value string is ");
//Serial.println(stringOne);
x=0;
hundreds = outputValue /100;
//Serial.print(hundreds);
delay(500);
switch (hundreds) {
case 3:
custom3();
break;
case 2:
custom2();
break;
case 1:
custom1();
break;
case 0:
custom0();
break;
}
tens=outputValue /10;
tens=tens%10;
//Serial.println(tens);
switch (tens) {
case 9:
x=x+3;
custom9();
break;
case 8:
x=x+3;
custom8();
break;
case 7:
x=x+2;
custom7();
break;
case 6:
x=x+3;
custom6();
break;
case 5:
x=x+3;
custom5();
break;
case 4:
x=x+3;
custom4();
break;
case 3:
x=x+3;
custom3();
break;
case 2:
x=x+3;
custom2();
break;
case 1:
x=x+3;
custom1();
break;
if (outputValue<10)
{
//case 0:
x=x+3;
custom0();
break;
}
case 0:
x=x+3;
custom0();
break;
}
ones=outputValue%10;
//ones=ones%100;
// Serial.println(ones);
switch (ones) {
case 9:
x=x+3;
custom9();
break;
case 8:
x=x+3;
custom8();
break;
case 7:
x=x+3;
custom7();
break;
case 6:
x=x+3;
custom6();
break;
case 5:
x=x+3;
custom5();
break;
case 4:
x=x+3;
custom4();
break;
case 3:
x=x+3;
custom3();
break;
case 2:
x=x+3;
custom2();
break;
case 1:
x=x+3;
custom1();
break;
case 0:
x=x+3;
custom0();
break;
}
/*
delay(500);
lcd.setCursor(0,1);
lcd.print(outputValue); */
//delay(300);
//lcd.clear();
//if (outputValue < 100)
// {
// x=0;
// lcd.print(" ");
// }
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
//delay(10);
}
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.