展开全部
把8031直接换成8951就行啦
管脚是一样的
电路如图
程序如下
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code LEDData[]=
{
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
};
sbit OE = P1^0;
sbit EOC = P1^1;
sbit ST = P1^2;
sbit CLK = P1^3;
void DelayMS(uint ms)
{
uchar i;
while(ms--)
{
for(i=0;i<120;i++);
}
}
void Display_Result(uchar d)
{
P2 = 0xf7;
P0 = LEDData[d%10];
DelayMS(5);
P2 = 0xfb;
P0 = LEDData[d%100/10];
DelayMS(5);
P2 = 0xfd;
P0 = LEDData[d/100];
DelayMS(5);
}
void main()
{
TMOD = 0x02;
TH0 = 0x14;
TL0 = 0x00;
IE = 0x82;
TR0 = 1;
P1 = 0x3f;
while(1)
{
ST = 0;
ST = 1;
ST = 0;
while(EOC == 0);
OE = 1;
Display_Result(P3);
OE = 0;
}
}
void Timer0_INT() interrupt 1
{
CLK = !CLK;
}
管脚是一样的
电路如图
程序如下
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code LEDData[]=
{
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
};
sbit OE = P1^0;
sbit EOC = P1^1;
sbit ST = P1^2;
sbit CLK = P1^3;
void DelayMS(uint ms)
{
uchar i;
while(ms--)
{
for(i=0;i<120;i++);
}
}
void Display_Result(uchar d)
{
P2 = 0xf7;
P0 = LEDData[d%10];
DelayMS(5);
P2 = 0xfb;
P0 = LEDData[d%100/10];
DelayMS(5);
P2 = 0xfd;
P0 = LEDData[d/100];
DelayMS(5);
}
void main()
{
TMOD = 0x02;
TH0 = 0x14;
TL0 = 0x00;
IE = 0x82;
TR0 = 1;
P1 = 0x3f;
while(1)
{
ST = 0;
ST = 1;
ST = 0;
while(EOC == 0);
OE = 1;
Display_Result(P3);
OE = 0;
}
}
void Timer0_INT() interrupt 1
{
CLK = !CLK;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
呵呵,如果谁有也顺便发给我吧,我也要做这个,十分感谢啊。我的542371324@qq.com
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
求连接方法 个图 有的5405001@qq.com
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询