可以了
#include <reg52.h>
sbit DI = P3^7; //HC595第14腳,串行數據
sbit CLK = P3^1; // HC595第11腳 ,數據時鐘
sbit LE = P3^2; // HC595第12腳 ,鎖存時鐘
sbit LEDEA = P3^3; //HC595第13腳 ,輸出控制
char code xscsj[] =
// {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
{ 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
char code zk [5][2][16] =
{
{{ 0x08,0x04,0x02,0x1F,0x10,0x10,0x1F,0x10,0x10,0x1F,0x00,0x00,0x7F,0x00,0x00,0x00,
},
{
0x08,0x10,0x20,0xFC,0x84,0x84,0xFC,0x84,0x84,0xFC,0x80,0x80,0xFF,0x80,0x80,0x80,
}}, /*-- 文字: 單 --*/
{{ /*-- 文字: 片 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x10,0x10,0x10,0x10,0x1F,0x10,0x10,0x10,0x1F,0x10,0x10,0x10,0x20,0x20,0x40,
} ,
{
0x40,0x40,0x40,0x40,0x40,0xFC,0x00,0x00,0x00,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,
}} ,
/*-- 文字: 機 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
{{
0x10,0x11,0x11,0x11,0xFD,0x11,0x31,0x39,0x55,0x55,0x91,0x11,0x11,0x12,0x12,0x14,
},
{
0x00,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x12,0x12,0x12,0x0E,0x00,
}} ,
/*-- 文字: 學 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
{{
0x22,0x11,0x11,0x00,0x7F,0x40,0x80,0x1F,0x00,0x01,0xFF,0x01,0x01,0x01,0x05,0x02,
},
{
0x08,0x08,0x10,0x20,0xFE,0x02,0x04,0xE0,0x40,0x80,0xFE,0x00,0x00,0x00,0x00,0x00,
}},
/*-- 文字: 習 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
{{
0x00,0x7F,0x00,0x00,0x08,0x04,0x02,0x02,0x00,0x01,0x0E,0x70,0x20,0x00,0x00,0x00,
},{
0x00,0xF8,0x08,0x08,0x08,0x08,0x08,0x08,0x68,0x88,0x08,0x08,0x08,0x08,0x50,0x20,
}},
} ;
void delay(int z) //延時函數
{
int x;
for (x=0; x<z; x++);
}
void yiwei (char i, char j,char k)
{
char n;
char di;
di=zk [i] [j][k];
for (n=0;n<8;n++)
{ CLK=0;
DI=(di&0x01) ;
// if(di&0x01)
// DI=1;
// else
// DI=0;
CLK=1;
di>>=1 ;
}
}
void xschs (int s)
{
if(s>7)
{ P2=0xff;
P0=xscsj[s-8];}
else
{P2=xscsj[s];
P0=0xff;}
}
void main() /*主函數*/
{ char i=0,j=0,k=0;
int s;
s=0;
LEDEA=0;
LE=0;
CLK=0;
while(1)
{
for(i=5;i>0;i--)
{
yiwei((i-1),1,k),
yiwei((i-1),0,k);
}
LE=1;
delay(10) ;
k++;
if(k>15)
k=0;
xschs(s);
s++;
if(s>15) s=0;
LE=0;
delay(10) ;
}
}
|