https://static.assets-stash.eet-china.com/album/old-resources/2009/5/14/79bb7b9f-6ef6-491a-9cb3-dcdc0bf03c45.rar#include <reg51.h>
unsigned int adval;
unsigned char i,m,n,x,y;
code unsigned char tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,
0x82,0xf8,0x80,0x90,0xff}; //共阳数码管段码
code unsigned char tab1_H[]=
{0x01,0x02,0x04,0x08,0x10,0x20,0x40,
0x80};
code unsigned char tab2_H[]=
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x04,0x08,0x10,0x20,0x40,
0x80};
code unsigned char tab2 []= {0xFF,0xDD,0xFD,0xDD,0x5D,0xED,0x51,0xED,0x55,0xF5,0x05,0x00,0x51,0xBD,0x5C,0xDD,
0x5D,0xF9,0x01,0xF4,0x55,0xED,0x55,0xD5,0x51,0x99,0xDD,0x3D,0xFD,0xBD,0xFF,0xFF};/*"襄",0*/
code unsigned char tab3 []= {0x7F,0xFD,0xB7,0xBD,0xD7,0xBD,0x00,0xDC,0xD7,0xDD,0xFD,0xED,0x53,0xF5,0xBB,0xF8,
0x55,0xF5,0xFF,0xED,0xB7,0xDD,0xD7,0x9D,0x00,0x3C,0xD7,0xBD,0xB7,0xFD,0xFF,0xFF};/*"樊",1*/
code unsigned char tab4 []= {0xBF,0xFF,0xCF,0xFD,0xEF,0xFD,0xED,0xFD,0xA3,0xFD,0xAB,0xFD,0xAF,0xBD,0xAE,0x7D,
0xA1,0x80,0x2B,0xFD,0xAF,0xFD,0xE7,0xFD,0xA8,0xFD,0xCD,0xFD,0xEF,0xFD,0xFF,0xFF};/*"学",2*/
code unsigned char tab5 []={0x01,0x00,0xFD,0xFF,0xCD,0xFD,0xB5,0xFB,0x79,0x7C,0xF3,0xBE,0xDB,0xCE,0xDB,0xF0,
0xDA,0xFE,0xD9,0xFE,0xDB,0x80,0xDB,0x7E,0xDB,0x7E,0xF3,0x7E,0xFB,0x0E,0xFF,0xFF};/*"院",3*/
code unsigned char tab7 []= {0xFF,0xFF,0xBF,0xFF,0x09,0x80,0xBB,0xED,0xBB,0xED,0x0B,0x80,0xBB,0x7F,0xF8,0xBE,
0x7B,0xDF,0x8B,0xE7,0xBB,0xF8,0xBB,0xF7,0xB9,0xCE,0x3F,0x9F,0xFF,0xDF,0xFF,0xFF};/*"嵌",4*/
code unsigned char tab8 []= {0xFF,0xBF,0xFF,0xDF,0xFF,0xEF,0xFF,0xF7,0xFE,0xF9,0x7C,0xFE,0x89,0xFF,0xE7,0xFF,
0x9F,0xFF,0x7F,0xFF,0xFF,0xFC,0xFF,0xFB,0xFF,0xE7,0xFF,0xCF,0xFF,0xEF,0xFF,0xFF};/*"入",5*/
sbit SCLK_L= P3^0;
sbit DIN_L= P3^1;
sbit RCLK_L= P3^2;
sbit SCLK_H= P3^3;
sbit DIN_H= P3^4;
sbit RCLK_H= P3^5;
//延时0.1ms个单位//
void delay (unsigned char h)
{ while(h--);
}
//延时0.1ms个单位//
//数据传输//
void sdata_L(void)
{
unsigned char c;
for(c=0;c<8;c++)
{
SCLK_L=0;
DIN_L=m &0x80;
m <<=1;
SCLK_L=1;
}
for(c=0;c<8;c++)
{ SCLK_L=0;
DIN_L=n&0x80;
n<<=1;
SCLK_L=1;
}
}
//数据输出//
void out_L(void)
{RCLK_L=0;
delay(40);
RCLK_L=1;
}
//数据输出//
//数据传输//
//数据传输//
void sdata_H(void)
{
unsigned char c;
for(c=0;c<8;c++)
{
SCLK_H=0;
DIN_H=x &0x80;
x <<=1;
SCLK_H=1;
}
for(c=0;c<8;c++)
{ SCLK_H=0;
DIN_H=y&0x80;
y<<=1;
SCLK_H=1;
}
}
//数据输出//
void out_H(void)
{RCLK_H=0;
delay(40);
RCLK_H=1;
}
//数据输出//
//数据传输//
void main ()
{
while (1)
{
for (i=0;i<16;i++)
{
if (i>=0 && i<8) {x= tab1_H;y=0;}
if (i>=8 && i<16) {y= tab2_H;x=0;}
sdata_H();
out_H();
m="tab5" [2*i];
n="tab5" [2*i+1];
sdata_L();
out_L();
delay (10);
}
}
}
用户1464024 2009-7-23 18:39