Creating a Custom LCD Character in MikroC PRO for PIC
In this video I demonstrate how to create a custom LCD character using MikroC Pro for PIC and the EasyPIC Development board by MikroElektronika http://www.mikroe.com . The microcontroller used in this tutorial is the Microchip PIC18F4685.
Here is the source code for the project:
12 Responses to “Creating a Custom LCD Character in MikroC PRO for PIC”
Leave a Reply
Note: Comments will have spelling errors corrected before they are posted. If you have a specific question please provide your email address so I can send you a direct reply.
Thats a nice little video, very informative and the code for it too, awesome.
Thanks .
Hi,
you can also use GLCD Font Creator MikroElektronika edition. It can also generate and let you create custom char projects for HD44780 controller.
Great tutorial! Keep it going. Looking forward for more!
hello there, how can i do this on a 128 x64 lcd, it doesnt have any custom charcter function. i use mikro C 8.2 and pic 18f4550.
My suggestion for you would be to look into the free MikroElektronika GLCD Font Creator to create characters for 128x64 GLCDs.
This function CustomCharacter doesn't work two times.
void CustomChar(char pos_row, char pos_char,int n) {
short i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character[n][i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
This string below doesn't work correctly:
CustomChar(1,3,2);
CustomChar(1,4,4);
Hi Siarhey.
MikroElektronika has a great tech support team that I have found really helpful. They could probably answer your question better than I can.
I don't have my easyPIC dev board near by right now to try this out but as a work-around to your issue you might try something like making a copy of the CustomChar function with a unique name like CustomCharA and CustomCharB and see if it responds differently.
Then try using the following commands:
Good Luck!
Regards,
Andrew
I wanted to ask is it possible to make text only in the second row shift left and right while the text in the first row remains?
Hi Anna.
It has been a while since I have used a traditional 16x2 LCD screen with MikroC Pro for PIC.
Here is a link to the MikroC Pro for PIC - LCD Library page. In their library example they demonstrate the _LCD_SHIFT_LEFT and _LCD_SHIFT_RIGHT Lcd Commands.
If you are not satisfied with the results from the MikroC shift commands you could create your own Circular Buffer array that would allow you to scroll text independently on either LCD row.
Regards,
Andrew Hazelden
Hey Andrew.
Wish you are fine and in good health.
I have a small problem that I need your help on as fast as possible. I am trying to make two custom characters in mikroC. First is an up arrow and the second is a down arrow. When I write the code and run the program the LCD shows the two characters up arrow. I don't know why so I need your help as fast as possible. This is the used code:
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
const char characterUp[] = {0,4,4,10,17,4,4,4};
void CustomCharUp(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(characterUp[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
const char characterDown[] = {4,4,4,4,17,10,4,4};
void CustomCharDown(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(characterDown[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
I need your help if you can. Thanks in advance.
Best Regards,
Muaz
Hi Muaz.
Here is a link to a MikroElektronika forum post that discusses the issue you are experiencing:
http://www.mikroe.com/forum/viewtopic.php?f=13&t=27000
According to Filip in the MikroE Forums the value in Lcd_Cmd(64); should be incremented by 8 address positions for each call.
Example:
Also you need to change the third value in LCD_Chr for each custom character address:
Try something like this:
Regards,
Andrew