#include <reg51.h>
unsigned char const tab[16]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
unsigned char code digittab[]={
0x18,0x18,0x0C,0x30,0x06,0x60,0x3F,0xFC,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x31,0x8C,
0x31,0x8C,0x3F,0xFC,0x01,0x80,0x01,0x80,0xFF,0xFF,0x01,0x80,0x01,0x80,0x01,0x80,
0x00,0x60,0x18,0x60,0x18,0x60,0x18,0x60,0x18,0x60,0x1F,0xFE,0x18,0x00,0x18,0x00,
0x18,0x00,0x1F,0xF0,0x18,0x30,0x18,0x30,0x18,0x30,0x30,0x30,0x30,0x30,0x60,0x30,
0x18,0x00,0x19,0xF8,0x19,0x98,0x19,0x98,0xFF,0x98,0x19,0x98,0x39,0x98,0x3D,0x98,
0x7F,0x98,0x7F,0x98,0xD9,0x98,0x19,0x9B,0x19,0x9B,0x1B,0x1B,0x1B,0x0F,0x1E,0x00,
0x0C,0x30,0x0C,0x18,0x19,0x8C,0x31,0x86,0x63,0xC0,0x06,0x60,0x0C,0x30,0x38,0x1C,
0xE0,0x07,0x1F,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0xF8,0x18,0x18,
0x3F,0xF8,0x07,0x70,0x01,0xC0,0x3F,0xFC,0x31,0x8C,0x3F,0xFC,0x31,0x8C,0x3F,0xFC,
0x31,0x8C,0x33,0x0C,0x03,0x00,0x7F,0xFC,0x06,0x0C,0x0C,0x0C,0x18,0x78,0x70,0x30,
0x00,0x00,0x00,0x00,0x00,0x20,0x0F,0xC0,0x04,0x80,0x04,0x80,0x04,0xFC,0x3F,0x84,
0x24,0x84,0x14,0x68,0x10,0x08,0x10,0xE8,0x1F,0x18,0x00,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x02,0x40,0x02,0x40,0x02,0x48,0x02,0x98,0x3E,0xA0,
0x02,0xC0,0x02,0x80,0x0E,0x82,0x72,0x42,0x02,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x0F,0xC0,0x00,0x80,0x00,0x80,0x00,0x80,
0x00,0x80,0x01,0x00,0x01,0x00,0x01,0x7E,0x7E,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x02,0x40,0x02,0x40,0x02,0x48,0x12,0x58,
0x1A,0x50,0x0A,0x60,0x02,0x40,0x02,0x40,0x03,0xFE,0x3C,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x78,0x1F,0x80,
0x01,0x00,0x01,0x80,0x02,0x80,0x02,0x40,0x04,0x20,0x08,0x38,0x10,0x04,0x00,0x00,
0x00,0x00,0x00,0x30,0x05,0x20,0x04,0x40,0x00,0x48,0x0F,0xBE,0x30,0x88,0x27,0xC0,
0x01,0x00,0x00,0xFC,0x3F,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xBC,0x04,0xCC,0x3A,0x84,0x22,0x78,0x1A,0x88,0x22,0x88,
0x22,0xF4,0x3E,0x84,0x20,0x84,0x01,0x04,0x01,0x0C,0x02,0x18,0x04,0x08,0x00,0x00,
0x00,0x00,0x00,0x60,0x04,0x40,0x08,0x70,0x10,0xC0,0x18,0x9C,0x0F,0xE4,0x0A,0xA8,
0x11,0xD0,0x30,0x30,0x50,0xCE,0x12,0x62,0x13,0x08,0x14,0x84,0x10,0x7C,0x00,0x00,
0x00,0x00,0x00,0x30,0x05,0x20,0x04,0x40,0x00,0x48,0x0F,0xBE,0x30,0x88,0x27,0xC0,
0x01,0x00,0x00,0xFC,0x3F,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0x3C,0x40,0x28,0x78,0x29,0x80,0x2A,0x20,0x2D,0xC0,
0x24,0x30,0x23,0xC0,0x20,0xC0,0x21,0x40,0x22,0x44,0x24,0x3E,0x00,0x00,0x00,0x00};
void delay(unsigned int i)
{
unsigned int j;
for(j=0;j<i;j++);
}
void main(void)
{
unsigned int j=0;
unsigned int q=0;
unsigned char r;
unsigned char t=0;
P1=0x00;
P3=0x00;
while(1)
{
for(r=0;r<20;r++)
for(j=q;j<32+q;j++)
{
P2=tab[t];
P3=digittab[j];
j++;
P1=digittab[j];
delay(150);
t++;
if(t==16)t=0;
}
q=q+32;
if(q==480)q=0;
}
}
这是源程序,求高手解答
回复【4楼】e315 陈。
delay(150);
这个延时的时间改小点,试试。
你主要是扫描速度不够快引起的。
-----------------------------------------------------------------------
是这个原因,把延时改小,这样不容易变暗。。
或者提高晶振频率,
不过这样亮度会减小。。。
-----------------------------------------------------------------------
是容易变暗
一周热门 更多>