Suppose you have to display a heart or love sign or any other logo to your lcd display. So lets make a trial.Its easy if you are simply go through this tutorial. MikroC has a powerful tool to display custom character in lcd.
You can draw custom character using this tool and it returns necessary codes for you.
In this tutorial we design + sign first ,and simulate it using proteus to view the result.
First open MikroC PRO for PIC and make a new project using pic16f73 with clock 20MHZ.
Go to Tools->LCD Custom Character
In next window design + sign by clicking rectangular boxes.Then press enter to generate code. Copy the full code to the.
Then paste the code under void main section shown below.Change the line
To this linevoid CustomChar(char pos_row, char pos_char)
void CustomChar1(char pos_row, char pos_char)
Then copy this line before void main shown below
Now just initialize lcd and call custochar1() in row 1 col 1 by writing
Lcd_Init(); // Initialize LCD
CustomChar1(1,1); //print + in lcd position row 1, column 1
Then Build the project and collect the hex file.
Open Proteus and draw the schema as shown below.
Load the hex file and in pic and oscillator will be 20 MHz.Then Run
Okey That’s Done!!!
Adding more characters
To add more character repeat the process again and now we shall design x sign with nameCustomChar2();But here is problem you have to face if you call
CustomChar2(1,3);You may see both
+ +sign rather than
+ xTo fix this problem you have change some code
Make two changes shown in figure above.
write
Lcd_Cmd(72); //every new character needs to add 8 e.g: 64+8=72rather than
Lcd_Cmd(64);And
Lcd_Chr(pos_row, pos_char, 1); //1 for 2nd characterrather than
Lcd_Chr(pos_row, pos_char, 0);Finally another divide sign I create named
CustomChar3();Call all three character at a time
void main() {Build the project and run in proteus. Output window I have
Lcd_Init(); // Initialize LCD
CustomChar1(1,1); //print + in lcd position row 1, column 1
CustomChar2(1,3); //print x in lcd position row 1, column 3
CustomChar3(1,5); //print Devide sign in lcd position row 1, column 5
}
Now you can design any custom character you need.
You can download the full project file from here Lcd Custom Character.rar
The proteus DSN file is here Lcd Custom character.DSN
No comments:
Post a Comment