为什么我8*8的点阵加了延时后只是闪了一下,而不是亮一会儿了呢#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code table1[]={0x00,0x00,0x02,0x03,0x02,0x00,0x00,0x00};
uchar code table2[]={0x00,0x00,0x04,0x06,0x04,0x00,0x00,0x00};
void delay(uint z)
{
while(z--);
}void main()
{
uint i; for(i=0;i<8;i++)
{
P2=table
;
P0=table1;
delay(50);
} delay(50000);
for(i=0;i<8;i++)
{
P2=table;
P0=table2;
delay(50);
} delay(50000);
while(1);}
此帖出自小平头技术问答
{
P2=table;
P0=table1;
delay(50);
}
delay(50000);
for(i=0;i<8;i++)
{
P2=table;
P0=table2;
delay(50);
}
delay(50000);
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code table1[]={0x00,0x00,0x02,0x03,0x02,0x00,0x00,0x00};
uchar code table2[]={0x00,0x00,0x04,0x06,0x04,0x00,0x00,0x00};
uint t,m;
void delay(uint z)
{
while(z--);
}
void t0() interrupt 1
{
TH0=(65536-50000)/256;
TH0=(65536-50000)%256;
m++;
}
void display1()
{
uchar i;
for(i=0;i<8;i++)
{
P2=table;
P0=table1;
delay(2);
}
}
void display2()
{
uchar i;
for(i=0;i<8;i++)
{
P2=table;
P0=table2;
delay(2);
}
}
void main()
{
uint i;
TMOD=0x01;
TH0=(65536-50000)/256;
TH0=(65536-50000)%256;
EA=1;
TR0=1;
ET0=1;
while(1)
{
for(m=0;m<2000;m++)
{
display1();
}
m=0;
for(m=0;m<2000;m++)
{
display2();
}
m=0;
}
}
- #include<reg52.h>
复制代码#define uchar unsigned char
#define uint unsigned int
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
unsigned char code table[]={0x00,0x20,0x28,0x78,0x28,0x20,0x00,0x00};
uchar code colum[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar i;
main()
{
while(1)
{
for(i=0;i<8;i++)
{
P0=table[i];
P2=colum[i];
delay(5);
P2=0xff;
}
}
}
一周热门 更多>