Hello!! I am using PIC16F877A micro-controller.
And i am trying to display multiple character on the same line..
But i am unable to so..
It is not displaying the characters as i want to..
it must diaplay the word Sawatam in Hindi below welcome in 2 row of LCD and then move it..
Can anyone help me..
here is my code..
// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
char txt1[] = "AMITESH CHAUHAN";
char txt2[] = "WELCOME";
unsigned int j;
const char character1[] = {31,28,4,4,15,4,2,1};
void CustomChar1(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character1);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
const char character2[] = {31,5,29,21,21,21,29,5};
void CustomChar2(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character2);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
const char character3[] = {31,5,5,5,5,29,21,29};
void CustomChar3(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character3);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
const char character4[] = {31,2,2,30,18,18,18,18};
void CustomChar4(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character4);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
const char character5[] = {31,5,5,5,31,31,13,5};
void CustomChar5(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character5);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
const char character6[] = {28,0,0,0,0,0,16,24};
void CustomChar6(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character6);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
void main() {
TRISB = 0x00;
Lcd_Init(); // Initialize LCD
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,txt1); // Write text in 1 row and 3 column
Delay_ms(3000);
Lcd_Cmd(_LCD_CLEAR);
Delay_ms(1000);
while(1)
{
Lcd_Out(1,1,txt2);
Delay_ms(1000);
//Custom Character Code to Display Sawagatam in Hindi
CustomChar1(2,1);
Delay_ms(1000);
CustomChar2(2,2);
CustomChar3(2,3);
CustomChar4(2,4);
CustomChar5(2,5);
CustomChar6(2,6);
Delay_ms(200);
for(i=1;i<=16;i++)
{
Lcd_Cmd(_LCD_SHIFT_LEFT);
Delay_ms(200);
}
}
}
Want 2 Disply Multiple LCD Custom Character on the same line
-
- Posts: 46
- Joined: 16 Apr 2011 14:37
Re: Want 2 Disply Multiple LCD Custom Character on the same
get some ideas from the following thread
Code: Select all
http://www.mikroe.com/forum/viewtopic.php?f=97&t=24647
Re: Want 2 Disply Multiple LCD Custom Character on the same
Working code tested on 16f887
~~~~~~~~~~~~~~~~
Take care of the following for your PIC
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
Code: Select all
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
char txt1[] = "AMITESH CHAUHAN";
char txt2[] = "WELCOME";
unsigned int j;
const char character1[] = {31,28,4,4,15,4,2,1};
void CustomChar1(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character1[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
const char character2[] = {31,5,29,21,21,21,29,5};
void CustomChar2(char pos_row, char pos_char) {
char i;
Lcd_Cmd(72);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character2[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 1);
}
const char character3[] = {31,5,5,5,5,29,21,29};
void CustomChar3(char pos_row, char pos_char) {
char i;
Lcd_Cmd(80);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character3[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 2);
}
const char character4[] = {31,2,2,30,18,18,18,18};
void CustomChar4(char pos_row, char pos_char) {
char i;
Lcd_Cmd(88);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character4[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 3);
}
const char character5[] = {31,5,5,5,31,31,13,5};
void CustomChar5(char pos_row, char pos_char) {
char i;
Lcd_Cmd(96);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character5[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 4);
}
const char character6[] = {28,0,0,0,0,0,16,24};
void CustomChar6(char pos_row, char pos_char) {
char i;
Lcd_Cmd(104);
for (i = 0; i<=7; i++) Lcd_Chr_CP(character6[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 5);
}
void main() {
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
Lcd_Init(); // Initialize LCD
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,txt1); // Write text in 1 row and 3 column
Delay_ms(3000);
Lcd_Cmd(_LCD_CLEAR);
while(1) {
Lcd_Out(1,1,txt2);
CustomChar1(2,1);
CustomChar2(2,2);
CustomChar3(2,3);
CustomChar4(2,4);
CustomChar5(2,5);
CustomChar6(2,6);
// YOUR CODE CONTINUES HERE
}
}
Take care of the following for your PIC
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
- Attachments
-
- ddd.jpg (116.9 KiB) Viewed 2910 times
Last edited by abcdefgg on 24 Jun 2011 09:20, edited 2 times in total.
Re: Want 2 Disply Multiple LCD Custom Character on the same
Code: Select all
Delay_ms(200);
for(i=1;i<=16;i++)
{
Lcd_Cmd(_LCD_SHIFT_LEFT);
Delay_ms(200);
"i" is used for the custom characters.
Check out the LCD library if you want to move the text left or right