KST-51:8*8点阵横向移动显示IG!

使用取模软件对 IG!一帧帧横向取模,将取模后每一帧(8*8点阵画面)的数据储存在二维数组中。一共有18帧画面。

image[][]数组中,行元素代表一帧画面,列元素代表当前帧中每一行。通过中断+switch遍历控制动态显示每一帧画面,从而实现视觉上像是IG!连续横向移动。

注:取模时,需要反向取模。即亮赋0,暗赋1。


#include<reg52.h>

sbit ADDR0=P1^0;
sbit ADDR1=P1^1;
sbit ADDR2=P1^2;
sbit ADDR3=P1^3;
sbit ENLED=P1^4;

unsigned char code image[17][8]=
{
{0xFF,0x83,0xEF,0xEF,0xEF,0xEF,0x83,0xFF},	 
{0xFF,0xC1,0xF7,0xF7,0xF7,0xF7,0xC1,0xFF},
{0xFF,0xE0,0xFB,0xFB,0xFB,0xFB,0xE0,0xFF},
{0xFF,0xF0,0x7D,0x7D,0x7D,0x7D,0xF0,0xFF},
{0xFF,0x78,0xBE,0xBE,0xBE,0xBE,0x78,0xFF},
{0xFF,0x3C,0xDF,0xDF,0x5F,0xDF,0x3C,0xFF},
{0xFF,0x1E,0xEF,0xEF,0x2F,0x6F,0x1E,0xFF},
{0xFF,0x0F,0xF7,0xF7,0x17,0xB7,0x8F,0xFF},
{0xFF,0x87,0xFB,0xFB,0x0B,0x5B,0x47,0xFF},
{0xFF,0xC3,0xFD,0xFD,0x85,0xAD,0xA3,0xFF},
{0xFF,0xE1,0xFE,0xFE,0xC2,0xD6,0xD1,0xFF},
{0xFF,0xF0,0xFF,0xFF,0xE1,0xEB,0xE8,0xFF},
{0xFF,0x78,0x7F,0x7F,0x70,0xF5,0x74,0xFF},
{0xFF,0xBC,0xBF,0xBF,0xB8,0xFA,0xBA,0xFF},
{0xFF,0xDE,0xDF,0xDF,0xDC,0xFD,0xDD,0xFF},
{0xFF,0xEF,0xEF,0xEF,0xEE,0xFE,0xEE,0xFF},
{0xFF,0xF7,0xF7,0xF7,0xF7,0xFF,0xF7,0xFF}
};

void main()
{

	EA=1;
	ENLED=0;		 
	ADDR3=0;		 
	TMOD=0x01;			 
	TH0=0xfc;			 
	TL0=0x67;
	ET0=1;
	TR0=1;				 

	while(1);
}
void InterruptTimer0() interrupt 1
{
	static unsigned char i=0;
	static unsigned char tmr=0;		 
 	static unsigned char index=0;  	

	TH0=0xfc;			 
	TL0=0x67;

	P0=0xff;

	switch(i)
	{
		case 0:ADDR2=0;ADDR1=0;ADDR0=0;P0=image[index][0];i++;break;   
		case 1:ADDR2=0;ADDR1=0;ADDR0=1;P0=image[index][1];i++;break;   
		case 2:ADDR2=0;ADDR1=1;ADDR0=0;P0=image[index][2];i++;break;
		case 3:ADDR2=0;ADDR1=1;ADDR0=1;P0=image[index][3];i++;break;
		case 4:ADDR2=1;ADDR1=0;ADDR0=0;P0=image[index][4];i++;break;
		case 5:ADDR2=1;ADDR1=0;ADDR0=1;P0=image[index][5];i++;break;
		case 6:ADDR2=1;ADDR1=1;ADDR0=0;P0=image[index][6];i++;break;
		case 7:ADDR2=1;ADDR1=1;ADDR0=1;P0=image[index][7];i=0;break;
		default:break;
	}
	tmr++;
	if(tmr>=250)
	{
		tmr=0;
		index++;
		if(index>=17)    
           	{
			index=0;
		}
	}
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值