LED点阵屏显示图形

LED点阵屏显示图形_第1张图片LED点阵屏显示图形_第2张图片

 

#include
#include "Delay.h"

sbit SRCLK=P3^6;   //SRCLK
sbit RCLK_=P3^5;   //RCLK
sbit SER=P3^4;	   //SER

#define MATRIX_LED_PORT P0

/*

74hc595 写入一个字节
*/
void _74HC595_WriteByte(unsigned char Byte)
{
//放入移位寄存器
	unsigned char i;
	for(i=0;i<8;i++)
	{
		SER=Byte & (0x80>>i);//>>i 
		SRCLK=1;//拉上升沿
		SRCLK=0;	
	}
	//输出
	RCLK_=1;
	RCLK_=0;

}

/*

LED点阵屏显示一列数据
Column 0~7
Data 0x00~0xff
*/
void MatrixLED_ShowColumn(unsigned char Column,Data)
{
	_74HC595_WriteByte(Data);
	MATRIX_LED_PORT=~(0x80>>Column);
	Delay(1);
	MATRIX_LED_PORT=0xff;//位清零	

}

void main()
{
	//P0=0x7f;//列选
	SRCLK=0;
	RCLK_=0;
	
	while(1)
	{
	   	MatrixLED_ShowColumn(0,0x3c);
		MatrixLED_ShowColumn(1,0x42);
		MatrixLED_ShowColumn(2,0xa9);
		MatrixLED_ShowColumn(3,0x85);
		MatrixLED_ShowColumn(4,0x85);
		MatrixLED_ShowColumn(5,0xa9);
		MatrixLED_ShowColumn(6,0x42);
		MatrixLED_ShowColumn(7,0x3c);
	}
}

 

你可能感兴趣的:(单片机,嵌入式硬件)