Professional Documents
Culture Documents
Bai 4
Bai 4
Bai 4
Bài 4: LCD
Bài 4: LCD
VC C
5V
R 1 10K LCD16x02
1
C 6
J1
5V LC D
104
9
8
7
6
5
4
3
2
9
8
7
6
5
4
3
2
1
16
15
14
13
12
11
10
10
U 1
40
EN
Rw
RS
1 39
2 P 1 .0 P 0 .0 /A D 0 38
VC C
3 P 1 .1 P 0 .1 /A D 1 37 5V
4 P 1 .2 P 0 .2 /A D 2 36
5 P 1 .3 P 0 .3 /A D 3 35
6 P 1 .4 P 0 .4 /A D 4 34
+ C 3 7 P 1 .5 P 0 .5 /A D 5 33
C A P A C IT O R P O L 8 P 1 .6 P 0 .6 /A D 6 32
9 P 1 .7 P 0 .7 /A D 7 31
10 R ST E A /V P P 30 R 2
11 P 3 .0 /R XD A L E /P R O G 29
P 3 .1 /T XD PSEN 5K
12 28 D 7
R 3 13 P 3 .2 /IN T 0 P 2 .7 /A 1 5 27 D 6
10K 14 P 3 .3 /IN T 1 P 2 .6 /A 1 4 26 D 5
15 P 3 .4 /T 0 P 2 .5 /A 1 3 25 D 4
16 P 3 .5 /T 1 P 2 .4 /A 1 2 24 D 3
17 P 3 .6 /W R P 2 .3 /A 1 1 23 D 2
18 P 3 .7 /R D P 2 .2 /A 1 0 22 D 1
19 XTA L2 P 2 .1 /A 9 21 D 0
XTA L1 P 2 .0 /A 8
GN D
Y 1
12M hz A T89C 51
20
C 2 C 1
33p 33p
Rw RS
EN
Bài 4: LCD
#include <REGX52.H>
#include <string.h>
#define LCDdata P2
sbit BF=P2^7;
sbit RS=P3^7;
sbit RW=P3^6;
sbit EN=P3^5;
Bài 4: LCD
void wait(void)
{
LCDdata=0xff;
while(BF){EN=0;delay(100);EN=1;delay(100);}
RW=0;
}
Bài 4: LCD
void display(int x)
{
convert(x);
P0=0x00;led1=1; P1 = maled7[i]; delay(100);
P0=0x00;led2=1; P1 = maled7[j]; delay(100);
P0=0x00;led3=1; P1 = maled7[k]; delay(100);
P0=0x00;led4=1; P1 = maled7[l]; delay(100);
}
Bài 3: LED_7_SEG
void main()
{
while(1)
{
display(1234);
}
}