-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLcd.mpas
101 lines (83 loc) · 2.26 KB
/
Lcd.mpas
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
{*
* Project name:
Segundo trabalho de Microcontroladores
*}
program Lcd;
// LCD module connections
var LCD_RS : sbit at RE2_bit;
var LCD_EN : sbit at RE1_bit;
var LCD_D4 : sbit at RD4_bit;
var LCD_D5 : sbit at RD5_bit;
var LCD_D6 : sbit at RD6_bit;
var LCD_D7 : sbit at RD7_bit;
var LCD_RS_Direction : sbit at TRISE2_bit;
var LCD_EN_Direction : sbit at TRISE1_bit;
var LCD_D4_Direction : sbit at TRISD4_bit;
var LCD_D5_Direction : sbit at TRISD5_bit;
var LCD_D6_Direction : sbit at TRISD6_bit;
var LCD_D7_Direction : sbit at TRISD7_bit;
// End LCD module connections
var txt1 : array[16] of char;
txt2 : array[15] of char;
txt3 : array[8] of char;
txt4 : array[7] of char;
mov : array[50] of char;
i , j ,g , h: byte;
tmp , aux : word;
procedure interrupt();
begin
PIR1.RCIF:=0;
PIR1.TMR1IF:=0;
for g:= 0 to 49 do
begin
mov[g]:= ADC_Read(0);
delay_ms(1);
end;
end;
begin
txt1 := 'Terceiro Trabalho';
txt2 := 'MicroControlador';
txt3 := '';
txt4 := 'Exemplo';
PWM1_Init(5000);
j:= 0;
i:= 0;
TRISC :=0;
PORTC := %00000000;
ADC_Init();
UART1_Init(9600);
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
LCD_Out(1,6,txt3); // Write text in first row
LCD_Out(2,6,txt4); // Write text in second row
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
LCD_Out(1,1,txt1);
Delay_ms(2000); // Write text in first row
Lcd_Cmd(_LCD_CLEAR);
TRISB :=0;
PORTB := %00000000;
g:= 0;
//Sound_init(PORTC,1); // Seta o buzzer da portc.1
INTCON.GIE:=1;
INTCON.PEIE:=1;
PIE1.RCIE:=1;
TMR1H := 0;
TMR1L := 0;
T1CON := 0;
while TRUE do // Endless loop
begin
LCD_Out(2,1,txt2);
i:= UART1_Read;
if i='L' then
begin
for j:= 0 to 49 do
begin
bytetostr(j, txt1);
LCD_Out(1,1, txt1);
UART1_Write(mov[j]);
end;
end;
end;
end.