程序应该没问题啊
#include "reg51.h"
#include "intrins.h"
typedef unsigned int u16;
typedef unsigned char u8;
sbit SRCLK=P3^6;
sbit RCLK=P3^5;
sbit SER=P3^4;
u8 code ledweixuan[]=
{
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80, /*这就是扫描*/
};
void delay(u16 i)
{
while(i--);
}
u8 code ledduan1[]=
{
/*-- 文字: 普 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x44,0x54,0x64,0x45,0x7E,0x44,0x44,0x44,0x7E,0x45,0x64,0x54,0x44,0x40,0x00,
0x00,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x00,0x00,0x00,
};
void Hc595SendByte(u8 dat1,u8 dat2,u8 dat3,u8 dat4)
{
u8 a;
SRCLK = 1;
RCLK = 1;
for(a=0;a<8;a++)
{
SER = dat1 >> 7;
dat1 <<= 1;
SRCLK = 0;
_nop_();
_nop_();
SRCLK = 1;
}
for(a=0;a<8;a++)
{
SER = dat2 >> 7;
dat2 <<= 1;
SRCLK = 0;
_nop_();
_nop_();
SRCLK = 1;
}
for(a=0;a<8;a++)
{
SER = dat3 >> 7;
dat3 <<= 1;
SRCLK = 0;
_nop_();
_nop_();
SRCLK = 1;
}
for(a=0;a<8;a++)
{
SER = dat4 >> 7;
dat4 <<= 1;
SRCLK = 0;
_nop_();
_nop_();
SRCLK = 1;
}
RCLK = 0;
_nop_();
_nop_();
RCLK = 1;
}
void main()
{
u8 i;
while(1)
{
for(i=0; i<16; i++)
{
Hc595SendByte(~ledweixuan[i+16],~ledweixuan[i],ledduan1[16+i],ledduan1[i]);
delay(10);
}
}
}
|