Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[AVR] lcd animation at 4 different location

Status
Not open for further replies.

Aayush Awasthi

Junior Member level 2
Junior Member level 2
Joined
Nov 18, 2013
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
128
how to use 4 lcd animation character at a time in a program at different location
 

it is LCD 16*2 in which 8 character are created as by there own wish so i want to create 4 special character at different location in LCD at position 0x80,0xc0,0x81,0xc1. but they are not creating in screen some how the code is below...


Code:
#include<avr/io.h>
#include<util/delay.h>



#define LCD_RS 0
#define LCD_RW 1
#define LCD_EN 2
#define LCD PORTD


void lcd_string(char*);
void lcd_config();
void lcd_cmd(unsigned char );
void lcd_data(unsigned char);
void animation1();
void animation2();
void animation3();
void animation4();
int main()
{

	DDRD=0xFF;
	lcd_config();
	lcd_cmd(0x01);
	_delay_ms(1000);
	while(1)
	{
	
	
	lcd_cmd(0x85);
	lcd_string("HAPPY");

	lcd_data(0);
	animation1();
	_delay_ms(1);
	
	animation2();
	_delay_ms(1);
	animation3();
	_delay_ms(1);
	lcd_data(3);
	lcd_cmd(0xc1);
	animation4();
	lcd_cmd(0xc2);
	lcd_string("ANNIVERSARY");
	lcd_data(0);
	animation4();
	_delay_ms(100);
	
	
		


	}
return 0;
}


void animation1()
{
	lcd_cmd(0x40);
	lcd_data(0b00000001);
	lcd_data(0b00000001);	
	lcd_data(0b00000001);
	lcd_data(0b00000111);
	lcd_data(0b00001111);
	lcd_data(0b00011111);
	lcd_data(0b00001111);
	lcd_data(0b00000011);
}

void animation2()
{
	lcd_cmd(0x48);
	lcd_data(0b00010000);
	lcd_data(0b00010000);	
	lcd_data(0b00010000);
	lcd_data(0b00011100);
	lcd_data(0b00011110);
	lcd_data(0b00011111);
	lcd_data(0b00011110);
	lcd_data(0b00011000);
	
}


void animation3()
{
	lcd_cmd(0x50);
	lcd_data(0b00000011);
	lcd_data(0b00000011);	
	lcd_data(0b00000011);
	lcd_data(0b00000011);
	lcd_data(0b00000011);
	lcd_data(0b00000011);
	lcd_data(0b00000011);
	lcd_data(0b00000011);

}



void animation4()
{
	lcd_cmd(0x60);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);

}





void lcd_string(char *str)
{
	unsigned int i=0;

		while(str[i]!='\0')
		{
			lcd_data(str[i]);
			i++;
		}
	/*		for(i=0;i<=50;i++)
	{
	lcd_cmd(0x1E);
	_delay_ms(100);
	}*/
}





void lcd_config()
{
	int i=0;
	lcd_cmd(0x02);
	lcd_cmd(0x06);
	lcd_cmd(0x28);
	lcd_cmd(0x0C);
	for(i=0;i<=50;i++)
	{
	lcd_cmd(0x1E);
	_delay_ms(10);
	}
}
void lcd_cmd(unsigned char x)
{
	LCD=x&0xF0;
	LCD&=~(1<<LCD_RS);
	LCD&=~(1<<LCD_RW);
	LCD|=(1<<LCD_EN); 
	_delay_ms(1);
	LCD&=~(1<<LCD_EN);



	LCD=(x<<4)&0xF0;
	LCD&=~(1<<LCD_RS);
	LCD&=~(1<<LCD_RW);
	LCD|=(1<<LCD_EN);
	_delay_ms(1);
	LCD&=~(1<<LCD_EN);
}
void lcd_data(unsigned char y)
{
	LCD=y&0xF0;
	LCD|=(1<<LCD_RS);
	LCD&=~(1<<LCD_RW);
	LCD|=(1<<LCD_EN);
	_delay_ms(1);
	LCD&=~(1<<LCD_EN);



	LCD=(y<<4)&0xF0;
	LCD|=(1<<LCD_RS);
	LCD&=~(1<<LCD_RW);
	LCD|=(1<<LCD_EN);
	_delay_ms(1);
	LCD&=~(1<<LCD_EN);
}
 
Last edited:

Each pattern has to be stored at different CGRAM location. I don't know what characters you are trying to display. It will be helpful if you post the images of characters needed.
 

i am using different CGRAM at location 0x40,0x48,0x50,0x60 but during running time only 1st animation is create at loaction 0x80 in LCD
 

ok sir when i use them i reply are they working or not
 

i use them but not correctly come and also patterns are just 4 different not imp. as pattern but i want to show on lcd 4 patterns at a time but not happen .i use ur loction for definining them .i attach the code pls see and tell me what changes i has to be done
Code:
#include<avr/io.h>
#include<util/delay.h>



#define LCD_RS 0
#define LCD_RW 1
#define LCD_EN 2
#define LCD PORTD


void lcd_string(char*);
void lcd_config();
void lcd_cmd(unsigned char );
void lcd_data(unsigned char);
void animation1();
void animation2();
void animation3();
void animation4();
int main()
{

	DDRD=0xFF;
	lcd_config();
	lcd_cmd(0x01);
	_delay_ms(10);
	while(1)
	{
	lcd_cmd(0x85);
	lcd_string("HAPPY");
	lcd_cmd(0xc2);
	lcd_string("ANNIVERSARY");

	animation1();
	_delay_ms(1);
	animation2();
	_delay_ms(1);
	animation3();
	_delay_ms(1);
	animation4();	
	//lcd_data(0);
	animation4();
	_delay_ms(100);
	
	
		


	}
return 0;
}


void animation1()
{
	lcd_data(0);
	lcd_cmd(0x64);
	lcd_data(0b00000001);
	lcd_data(0b00000001);	
	lcd_data(0b00000001);
	lcd_data(0b00000111);
	lcd_data(0b00001111);
	lcd_data(0b00011111);
	lcd_data(0b00001111);
	lcd_data(0b00000011);
}

void animation2()
{
	lcd_data(0);
	lcd_cmd(0x72);
	lcd_data(0b00010000);
	lcd_data(0b00010000);	
	lcd_data(0b00010000);
	lcd_data(0b00011100);
	lcd_data(0b00011110);
	lcd_data(0b00011111);
	lcd_data(0b00011110);
	lcd_data(0b00011000);
	
}


void animation3()
{
	lcd_data(0);
	lcd_cmd(0x80);
	lcd_data(0b00000011);
	lcd_data(0b00000011);	
	lcd_data(0b00000011);
	lcd_data(0b00000011);
	lcd_data(0b00000011);
	lcd_data(0b00000011);
	lcd_data(0b00000011);
	lcd_data(0b00000011);

}



void animation4()
{
	lcd_data(0);
	lcd_cmd(0x88);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);
	lcd_data(0b00011000);

}





void lcd_string(char *str)
{
	unsigned int i=0;

		while(str[i]!='\0')
		{
			lcd_data(str[i]);
			i++;
		}
	/*		for(i=0;i<=50;i++)
	{
	lcd_cmd(0x1E);
	_delay_ms(100);
	}*/
}





void lcd_config()
{
	int i=0;
	lcd_cmd(0x02);
	lcd_cmd(0x06);
	lcd_cmd(0x28);
	lcd_cmd(0x0C);
	for(i=0;i<=50;i++)
	{
	lcd_cmd(0x1E);
	_delay_ms(10);
	}
}
void lcd_cmd(unsigned char x)
{
	LCD=x&0xF0;
	LCD&=~(1<<LCD_RS);
	LCD&=~(1<<LCD_RW);
	LCD|=(1<<LCD_EN); 
	_delay_ms(1);
	LCD&=~(1<<LCD_EN);



	LCD=(x<<4)&0xF0;
	LCD&=~(1<<LCD_RS);
	LCD&=~(1<<LCD_RW);
	LCD|=(1<<LCD_EN);
	_delay_ms(1);
	LCD&=~(1<<LCD_EN);
}
void lcd_data(unsigned char y)
{
	LCD=y&0xF0;
	LCD|=(1<<LCD_RS);
	LCD&=~(1<<LCD_RW);
	LCD|=(1<<LCD_EN);
	_delay_ms(1);
	LCD&=~(1<<LCD_EN);



	LCD=(y<<4)&0xF0;
	LCD|=(1<<LCD_RS);
	LCD&=~(1<<LCD_RW);
	LCD|=(1<<LCD_EN);
	_delay_ms(1);
	LCD&=~(1<<LCD_EN);
}
 

Test this in Proteus and also hardware. If you tell exactly what animated character should result then I will try to write a code.

Simulation video attached.

Try this code. I have modified your code. I Haven't checked your LCD code. Does your LCD code display "Happy Anniversary"?


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include <avr/io.h>
 
#define F_OSC 4000000
 
#include <util/delay.h>
 
#define _LCD_RETURN_HOME 0x02
 
#define LCD_RS 0
#define LCD_RW 1
#define LCD_EN 2
#define LCD PORTD
 
void LCD_Out(char*);
void LCD_Init();
void LCD_Cmd(unsigned char);
void LCD_Chr(unsigned char);
void CustomChar(char pos_row, char pos_char);
 
const char characterAnim[4][8] = {
      {1,1,1,7,15,31,15,3},
      {16,16,16,28,30,31,30,24},
      {3,3,3,3,3,3,3,3},
      {24,24,24,24,24,24,24,24}
};
      
void CustomChar(char pos_row, char pos_char){
    unsigned char i, j = 0, value;
  
    for(j = 0; j < 4; j++){
        LCD_Cmd(64 + (j * 8));
        for (i = 0; i <= 7; i++) Lcd_Chr(characterAnim[j][i]);
        LCD_Cmd(_LCD_RETURN_HOME);
 
    switch(pos_row){
        case 1:
            value = 0x80 + pos_char;
            break;
        case 2:
            value = 0xC0 + pos_char;
            break;
        case 3:
            value = 0x94 + pos_char;
            break;
        case 4:
            value = 0xD4 + pos_char;
            break;
 
    };
 
        Lcd_Cmd(value); 
        _delay_ms(250);
    }
}
 
void LCD_Init(){
 
    int i = 0;
 
    LCD_Cmd(0x02);
    LCD_Cmd(0x06);
    LCD_Cmd(0x28);
    LCD_Cmd(0x0C);
 
    for(i=0; i <= 50; i++){
        LCD_Cmd(0x1E);
        _delay_ms(10);
    }
}
 
void LCD_Cmd(unsigned char x){
 
    LCD = x & 0xF0;
    LCD &= ~(1 << LCD_RS);
    LCD &= ~(1 << LCD_RW);
    LCD |= (1 << LCD_EN); 
    _delay_ms(1);
    LCD &= ~(1 << LCD_EN);
 
 
 
    LCD = (x << 4) & 0xF0;
    LCD &= ~(1 << LCD_RS);
    LCD &= ~(1 << LCD_RW);
    LCD |= (1 << LCD_EN);
    _delay_ms(1);
    LCD &= ~(1 << LCD_EN);
}
 
void LCD_Chr(unsigned char y){
 
    LCD = y & 0xF0;
    LCD |= (1 << LCD_RS);
    LCD &= ~(1 << LCD_RW);
    LCD |= (1 << LCD_EN);
    _delay_ms(1);
    LCD& = ~(1 << LCD_EN);
 
    LCD = (y << 4) & 0xF0;
    LCD |= (1 << LCD_RS);
    LCD &= ~(1 << LCD_RW);
    LCD |= (1 << LCD_EN);
    _delay_ms(1);
    LCD &= ~(1 << LCD_EN);
}
 
void LCD_Out(char *str){
 
    unsigned int i = 0;
 
        while(*str)
        {
            LCD_Chr(*str++);            
        }   
}
 
 
 
int main()
{
 
    DDRD = 0xFF;
    PORTD = 0x00;
 
    LCD_Init();
    LCD_Cmd(0x80);
    LCD_Out("Happy");
    LCD_Cmd(0xC0);
    LCD_Out("Anniversary");
    
    while(1){
    
        CustomChar(2, 14);
 
    }
 
    return 0;
}

 

Attachments

  • LCD ANIM.rar
    15.9 KB · Views: 105
  • anim.rar
    10.1 KB · Views: 94
Last edited:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top