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

复制代码
#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]);
	}
}
相关推荐
fengfuyao98521 小时前
利用 STM32 和 ADS1256 进行高精度数据采集
stm32·单片机·嵌入式硬件
黑白园1 天前
ADC读取XY二轴操纵杆数据通过I2C_GPIO模拟 控制0.96寸OLED显示
stm32·单片机·嵌入式硬件
一个平凡而乐于分享的小比特1 天前
还在手动挡写单片机?MicroPython 一脚油门踩进 Python 硬件世界
单片机·嵌入式硬件·micropython
FreakStudio1 天前
WIZnet-EVB-Pico2开始,用MicroPython玩转以太网开发
python·单片机·嵌入式·大学生·面向对象·技术栈·并行计算·电子diy·电子计算机
LCG元1 天前
STM32实战:基于STM32F103的工业仪表数据采集(多路ADC)
stm32·单片机·嵌入式硬件
BT-BOX1 天前
Stm32CubeMX+Proteus仿真--STM32外部中断
stm32·单片机·proteus
Wallystech-Linda1 天前
DR9574 vs DR9574S — Choosing the Right IPQ9574 WiFi 7 Platform for Your Network
嵌入式硬件
森利威尔电子-1 天前
森利威尔SL8700 降压型大功率 LED 恒流驱动器:5A/95%效率,支持 PWM/模拟调光
单片机·嵌入式硬件·集成电路·芯片·电源芯片
三佛科技-187366133971 天前
GP8892SEH贴片SOP7省外围5V2A隔离型原边反馈芯片直接替代MT3723
单片机·嵌入式硬件
Quinn271 天前
正点原子 STM32MP257 修复异核 FreeRTOS 例程 osDelay() 函数比 HAL_Delay() 延时快的问题
stm32·单片机·嵌入式硬件