Академический Документы
Профессиональный Документы
Культура Документы
BI TIU LUN
MN : THC HNH VI X L
Bi 1: V mch m phng trn Proteus v vit chng trnh trn Keil C hin th
pht giy trn LED 7 on ng vi thi gian thc.
Mch. M phng vi x l hin th pht giy trn LED 7 on trong Proteus.
B1
B2
B3
B4
B5
B6
B7
B1
B2
B3
B4
B5
B6
B7
220220220220220220220
U1
AT89C52
1
2
3
4
5
6
7
8
P1.0/T2
P1.1/T2EX
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
P3.0/RXD
P3.1/TXD
P3.2/INT0
P3.3/INT1
P3.4/T0
P3.5/T1
P3.6/WR
P3.7/RD
10
11
12
13
14
15
16
17
220220220220220220220
R16
R15
R14
R5R12
R11
R10
220220220220220220220
C1
C2
C3
C4
C5
C6
C7
PSEN
ALE
EA
P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14
P2.7/A15
29
30
31
RST
9
XTAL2
18
21
22
23
24
25
26
27
28
R24
R23
R22
R21
R20
R19
R18 R32
R31
R30
R29
R28
R27
R26
220220220220220220220
39
38
37
36
35
34
33
32
R8R7R6R1R4R3R2
P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7
XTAL1
19
A1
A2
A3
A4
A5
A6
A7
A1
A2
A3
A4
A5
A6
A7
C1
C2
C3
C4
C5
C6
C7
D1
D2
D3
D4
D5
D6
D7
D1
D2
D3
D4
D5
D6
D7
Chng trnh:Hin th pht giy trn LED 7 on ng vi thi gian thc trn Keil
C.
#include <REGX51.H>
#include<stdio.h>
unsigned char mang[10]={64,121,36,48,25,18,2,120,0,16};
void delay(int t)
{
unsigned long int i;
for(i=0;i<t;i++);
}
void main()
{
{
dem=0;
if(++dem1==60)
dem1=0;
if(dem >= 59)
SauPhut++;
}
if(SauPhut==9)
{
TruocPhut++;
SauPhut=0;
}
delay(8000);
}
}
1
2
3
4
5
6
7
8
29
30
31
18
19
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
PSEN
ALE
EA
RST
XTAL2
XTAL1
P3.0/RXD
P3.1/TXD
P3.2/INT0
P3.3/INT1
P3.4/T0
P3.5/T1
P3.6/WR
P3.7/RD
P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14
P2.7/A15
P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7
10
11
12
13
14
15
16
17
21
22
23
24
25
26
27
28
39
38
37
36
35
34
33
32
7
8
9
10
11
12
13
14
4
5
6
1
2
3
D0
D1
D2
D3
D4
D5
D6
D7
RS
RW
E
VSS
VDD
VEE
Bi 2 : Thit k mch m phng trn Proteus v vit chng trnh cho LCD hin
LCD1
LM032L
R17 6 5 4 3 2 1
220220220220220220220220
U1
AT89C51
Chng trnh: Hin th gi pht giy trn LCD ng vi thi gian thc trn Keil C.
#include <REGX52.H>
#include <stdio.H>
#include <string.H>
#define dulieu P3
sbit RS=P2^0;
sbit RW=P2^1;
sbit EN=P2^2;
unsigned char maled[]={'0','1','2','3','4','5','6','7','8','9'};
unsigned char a[10];
int i=0;
int dem=0,dem1=0,giay=0,giay1=0,phut=0,phut1=0;
void delay(int t)
{
unsigned long int i;
for(i=0;i<t;i++);
}
void ghilenh(unsigned char c)
{
RS=0;
RW=0;
dulieu=c;
EN=0;delay(10);
EN=1;delay(10);
EN=0;delay(10);
}
if(++dem==60)
{
dem=0;
if(++dem1==60)
{
dem1=0;
if(++giay==60)
{
giay=0;
}
}
}
delay(15000);
ghilenh(0xc0);
chuoi("Bay Gio La:");
a[0]=maled[giay/10];
a[1]=maled[giay%10];
a[2]=maled[dem1/10];
a[3]=maled[dem1%10];
a[4]=maled[dem/10];
a[5]=maled[dem%10];
chuoi(a);
}
}
void main()
{
khoidonglcd();
ghilenh(0x80);
chuoi("ThucHanh ViDieuKhien");
hienthi();
}
Cu 3: Thit k mch m phng trn Proteus v vit chng trnh trn Keil C lm
my tnh b ti hin th trn LCD.
Mch: M phng mch my tnh b ti trn Proteus.