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
| // 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 MonsterMouthOpened[] = {15,9,9,12,12,8,9,15};
const char MonsterMouthClosed[] = {15,9,9,13,13,9,9,15};
void MonsterMouth1(char pos_row,char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(MonsterMouthOpened[i]);
Lcd_Cmd(_LCD_RETURN_HOME); //returns cursor to original display
Lcd_Chr(pos_row, pos_char, 0); // row,char to be out,col
}
void MonsterMouth2(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i =0; i<=7; i++)
Lcd_Chr_CP(MonsterMouthClosed[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
void main(){
char k =1;
char j=1;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
while(1)
{
MonsterMouth1(j, k) ;
delay_ms(10);
MonsterMouth2(j, k) ;
delay_ms(10);
k++;
Lcd_Cmd(_LCD_CLEAR);
if(k==17)
{j++;
k=1;
}
if(j==3) {
j=1;
}
}
} |