【Proteus】LED点阵屏显示动画&图像

13 篇文章 0 订阅
6 篇文章 0 订阅

#include <REGX51.H>
sbit RCLK=P3^5;
sbit SRCLK=P3^3;
sbit SER=P3^4;
void delay(unsigned char n)
{
	int i,j;
	for(i=0;i<n;i++)
	{
		for(j=0;j<120;j++);
	}
}
void _74HC595_writebyte(unsigned char byte)
{
	unsigned char i;
	for(i=0;i<8;i++)
	{
		SER=byte&(0x80>>i); //1000 0000->0100 0000->0010 0000
		SRCLK=1;
		SRCLK=0;
	}
	RCLK=1;
	RCLK=0;
}
void matrixled_show(unsigned char column,unsigned char Data)
{
	_74HC595_writebyte(Data);	
	P2=~(0x80>>column);//1000 0000
	delay(1);
	P2=0xff;//位清0
}
void main()
{
	SRCLK=0;
	RCLK=0;
	//_74HC595_writebyte(0xf0);//由实验现象可知,高位是1,低位是0
	while(1)
	{
		matrixled_show(0,0x80);//放在while外,不亮,因为delay很短,且位清零
		matrixled_show(1,0x40);	
		matrixled_show(2,0x20);
		matrixled_show(3,0x10);	
		matrixled_show(4,0x10);
		matrixled_show(5,0x10);
		matrixled_show(6,0x10);
		matrixled_show(7,0x10);
	}
}

#include <REGX51.H>
sbit RCLK=P3^5;
sbit SRCLK=P3^3;
sbit SER=P3^4;
unsigned char  animation[]={
0xFF, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x0E, 0x15, 0x15, 0x15, 0x08, 0x00, 0x7E, 0x01, 0x02, 0x00,
0x7E, 0x01, 0x02, 0x00, 0x0E, 0x11, 0x11, 0x0E, 0x00, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
void delay(unsigned char n)
{
	int i,j;
	for(i=0;i<n;i++)
	{
		for(j=0;j<120;j++);
	}
}
void _74HC595_writebyte(unsigned char byte)
{
	unsigned char i;
	for(i=0;i<8;i++)
	{
		SER=byte&(0x80>>i); //1000 0000->0100 0000->0010 0000
		SRCLK=1;
		SRCLK=0;
	}
	RCLK=1;
	RCLK=0;
}
void matrixled_init()//点阵屏初始化
{
	SRCLK=0;
	RCLK=0;
}
void matrixled_show(unsigned char column,unsigned char Data)
{
	_74HC595_writebyte(Data);	
	P2=~(0x80>>column);//1000 0000
	delay(1);
	P2=0xff;//位清0
}
void main()
{
	unsigned char i,Offset=0,count=0;
	matrixled_init();
	//_74HC595_writebyte(0xf0);//由实验现象可知,高位是1,低位是0
	while(1)
	{
		for(i=0;i<8;i++)
		{
			matrixled_show(i,animation[i+Offset]);//放在while外,不亮,因为delay很短,且位清零
		}
		count++;
		if(count>10)  //相当于延时
		{
			count=0;
			Offset++;
			if(Offset>24)//32-8
			{
				Offset=0;
			}
		}
//		matrixled_show(0,animation[0]);//放在while外,不亮,因为delay很短,且位清零
//		matrixled_show(1,animation[1]);	
//		matrixled_show(2,animation[2]);
//		matrixled_show(3,animation[3]);	
//		matrixled_show(4,animation[4]);
//		matrixled_show(5,animation[5]);
//		matrixled_show(6,animation[6]);
//		matrixled_show(7,animation[7]);
	}
}

 

  • 10
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值