#include <REGX52.H>
#include "DELAY.h"
#include "MatrixLED.h"
unsigned char code Animation[]={
0x3F,0xA1,0x69,0x23,0x23,0x69,0xA1,0x3F,
0x3F,0x61,0x69,0x23,0x23,0x69,0x61,0x3F,
};
void main()
{
unsigned char i,Offset=0,Count=0;
MatrixLED_Init();
while(1)
{
for(i=0;i<8;i++)
{
MatrixLED_ShowColumn(i,Animation[i+Offset]);
}
Count++;
if(Count>20)
{
Count=0;
Offset+=8;
if(Offset>8)
{
Offset=0;
}
}
}
}
#include <REGX52.H>
#include "DELAY.h"
sbit RCK=P3^5;//位申明,重新命名 RCLK
sbit SCK=P3^6;//时钟 SRCLK
sbit SER=P3^4;//SER
#define MATRIX_LED_PORT P0
/**
* @brief 74HC595写入一个字节
* @param 要写入的字节
* @retval 无
*/
void _74HC595_WriteByte(unsigned char Byte)//移位计时器
{
unsigned char i;
for(i=0;i<8;i++)
{
SER=Byte&(0x80>>i);
SCK=1;
SCK=0;
}
RCK=1;
RCK=0;
}
/**
* @brief 点阵屏初始化
* @param 无
* @retval 无
*/
void MatrixLED_Init()
{
SCK=0;
RCK=0;
}
/**
* @brief LED点阵屏显示一列数据
* @param Column要选择的列,范围0—7,0在最左边
Data要选择的显示的数据,高位在上,1为亮,0为灭
* @retval 无
*/
void MatrixLED_ShowColumn(unsigned char Column,Data)//点阵屏
{
_74HC595_WriteByte(Data);
P0=~(0x80>>Column);//移位操作
Delay(1);
MATRIX_LED_PORT=0xFF;//位清零
}