本帖最后由 tangjiaqq 于 2014-5-10 01:03 编辑
新手不怎么会,希望有,电路图,程序,交作业啊
#include <reg51.h>
#define uchar unsigned char
uchar duanma[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//
uchar weima[4]={0xfe,0xfd,0xfb,0x07};//
uchar nanbei[3]={25,20,5};
uchar dongxi[3]={20,5,25};
uchar nbdeng[3]={0x01,0x04,0x02};
uchar dxdeng[3]={0x80,0x40,0x20};
uchar jishu1,jishu2,dxjishu,nbjishu,dxmiao,nbmiao;
uchar xianshi[4]={0,0,0,0};
void chushihua(void)
{
TMOD=0x01;
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
EA=1;ET0=1;TR0=1;
}
sbit k1 = P3^1;
sbit k2 = P3^6;
void yansi02s(void)
{
uchar i,j,k;
for(i=7;i>0;i--)
for(j=8;j>0;j--)
for(k=34;k>0;k--);
}
void main(void)
{
dxmiao=dongxi[0];
nbmiao=nanbei[0];
P3=dxdeng[0]|nbdeng[0];
chushihua();
while(1)
{
if((dxjishu==0)&&(dxmiao==0))
{
k2=~k2;
yansi02s();
}
if((nbjishu==0)&&(nbmiao==0))
{
k1=~k1;
yansi02s();
}
}
}
void daojishi (void ) interrupt 1
{
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
xianshi[0]=duanma[nbmiao/10];
xianshi[1]=duanma[nbmiao%10];
xianshi[2]=duanma[dxmiao/10];
xianshi[3]=duanma[dxmiao%10];
jishu1++;
if(jishu1==4)jishu1=0;
P2=weima[jishu1];
P1=xianshi[jishu1];
P3=dxdeng[dxjishu]|nbdeng[nbjishu];
jishu2++;
if(jishu2==100)
{
jishu2=0;
dxmiao--;nbmiao--;
if(dxmiao==0xff)
{
dxjishu++;
if(dxjishu==3)dxjishu=0;
dxmiao=dongxi[dxjishu];
}
if(nbmiao==0xff)
{
nbjishu++;
if(nbjishu==3) nbjishu=0;
nbmiao=nanbei[nbjishu];
}
}
}
我想是想 黄灯的时候闪烁 怎么弄 弄了一晚上还是不行
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>