代码如下:
#include <reg52.h>
#include <intrins.h>
#include "bstv51.h"
sbit dula=P2^6;
sbit wela=P2^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar code table1[]={
0xfe,0xfd,0xfb,0xf7,
0xef,0xdf,0xbf,0x7f};
uchar temp,num,num1;
uint counter,x,y;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=400;y>0;y--);
}
void main()
{
counter=0;
num=0;
num1=0;
P1=0xfe;
temp=0xfe;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65535-50000)%256;
EA=1;
ET0=1;
TR0=1;
dula=1;
P0=table[0];
dula=0;
wela=1;
P0=table1[0];
wela=0;
while(1)
{
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65535-50000)%256;
counter++;
if(counter==20)
{
counter=0;
num1++;
if(num1==8)
num1=0;
wela=1;
P0=table[num1];
wela=0;
num++;
if(num==8)
num=0;
dula=1;
P0=table[num];
dula=0;
}
}
现在的现象就是随机出现0~7,看动图~~
#include <reg52.h>
#include <intrins.h>
#include "bstv51.h"
sbit dula=P2^6;
sbit wela=P2^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar code table1[]={
0xfe,0xfd,0xfb,0xf7,
0xef,0xdf,0xbf,0x7f};
uchar temp,num,num1;
uint counter,x,y;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=400;y>0;y--);
}
void main()
{
counter=0;
num=0;
num1=0;
P1=0xfe;
temp=0xfe;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65535-50000)%256;
EA=1;
ET0=1;
TR0=1;
dula=1;
P0=table[0];
dula=0;
wela=1;
P0=table1[0];
wela=0;
while(1)
{
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65535-50000)%256;
counter++;
if(counter==20)
{
counter=0;
num1++;
if(num1==8)
num1=0;
wela=1;
P0=table[num1];
wela=0;
num++;
if(num==8)
num=0;
dula=1;
P0=table[num];
dula=0;
}
}
现在的现象就是随机出现0~7,看动图~~