标题:
单片机进行数学运算与显示实验
[打印本页]
作者:
liuda
时间:
2015-1-21 22:46
标题:
单片机进行数学运算与显示实验
是用51hei单片机开发板 电路图详见:
http://www.51hei.com/f/51hei-5.pdf
的数码管部分, 用2个74hc573 锁存,p0口作为数据口 ,p3.6和p3.7分别是段和位的锁存端口.
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code SEG7[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit D=P3^6;
sbit V=P3^7;
void delay(uint k);
//=================
void main(void)
{
uchar a,b,c,out;
a=100;
b=60;
c=9;
out=a+3*(b-c)/2;
while(1)
{
D=1;
P0=SEG7[out/100];
D=0;
P0=0xff;
V=1;
P0=0xfe;
V=0;
delay(1);
D=1;
P0=SEG7[(out%100)/10];
D=0;
P0=0xff;
V=1;
P0=0xfd;
V=0;
delay(1);
D=1;
P0=SEG7[out%10];
D=0;
P0=0xff;
V=1;
P0=0xfb;
V=0;
delay(1);
}
}
//=====================
void delay(uint k)
{
uint i,j;
for(i=0;i<k;i++){
for(j=0;j<121;j++)
{;}}
}
复制代码
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1