LED点阵屏显示静态图案
#include <REGX52.H>
#include "Delay.h"
sbit RCK=P3^5;//RCLKÖض¨Òå
sbit SCK=P3^6;//SCLK
sbit SER=P3^4;//SER
#define MATRIX_LED_PORT P0
/**
* @brief 74HC595дÈëµÄÒ»¸ö×Ö½Ú
* @param Byte ҪдÈëµÄ×Ö½Ú
* @retval ÎÞ
*/
void _74HC595_WriteByte(unsigned char Byte)//°ÑÊý¾ÝдÈë8¸ö²ÎÊýÒý½Å
{
unsigned char i;
for(i=0;i<8;i++)
{
SER=Byte&(0x80>>i);
SCK=1;
SCK=0;
}
RCK=1;
RCK=0;
}
/**
* @brief LEDµãÕóÆÁÏÔʾһÁÐÊý¾Ý
* @param Column ҪѡÔñµÄÁУ¬·¶Î§:0~7,´Ó×óÖÁÓÒ
* @param Data Ñ¡ÔñÁÐÏÔʾµÄÊý¾Ý 1ÁÁ0Ãð
* @retval ÎÞ
*/
void MatrixLED_ShowColumn(unsigned char Col,Data)//Data 0~7
{
_74HC595_WriteByte(Data);
MATRIX_LED_PORT=~(0x80>>Col);
Delay(1);
MATRIX_LED_PORT=0xFF;
}
void main()
{
SCK=0;
RCK=0;
while(1)
{
MatrixLED_ShowColumn(0,0xF8);
MatrixLED_ShowColumn(1,0x9C);
MatrixLED_ShowColumn(2,0xC6);
MatrixLED_ShowColumn(3,0x63);
MatrixLED_ShowColumn(4,0x63);
MatrixLED_ShowColumn(5,0xC6);
MatrixLED_ShowColumn(6,0x9C);
MatrixLED_ShowColumn(7,0xF8);
}
}