这是原理图
程序如下
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table1 []=//取模方法,阴码,逆向,逐列式,
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x70,0x38,0x88,0x20,0x08,0x21,0x08,0x21,0x08,0x22,0x38,0x1C,0x00,0x00,/*"S",0*/
0x00,0x00,0xF8,0x19,0x88,0x20,0x88,0x20,0x88,0x20,0x08,0x11,0x08,0x0E,0x00,0x00,/*"5",1*/
0x00,0x00,0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,/*"1",2*/
0x00,0x00,0x70,0x1C,0x88,0x22,0x08,0x21,0x08,0x21,0x88,0x22,0x70,0x1C,0x00,0x00,/*"8",3*/
0x00,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0xFC,0x3F,
0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x00,0x20,0x00,0x00,/*"?",4*/
0x00,0x01,0x80,0x00,0x60,0x00,0xF8,0xFF,0x07,0x00,0x40,0x00,0x30,0x00,0x0F,0x00,
0xF8,0xFF,0x88,0x08,0x88,0x08,0x88,0x08,0x88,0x08,0x08,0x08,0x08,0x00,0x00,0x00,/*"?",5*/
};
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table1 []=//取模方法,阴码,逆向,逐列式,
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x70,0x38,0x88,0x20,0x08,0x21,0x08,0x21,0x08,0x22,0x38,0x1C,0x00,0x00,/*"S",0*/
0x00,0x00,0xF8,0x19,0x88,0x20,0x88,0x20,0x88,0x20,0x08,0x11,0x08,0x0E,0x00,0x00,/*"5",1*/
0x00,0x00,0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,/*"1",2*/
0x00,0x00,0x70,0x1C,0x88,0x22,0x08,0x21,0x08,0x21,0x88,0x22,0x70,0x1C,0x00,0x00,/*"8",3*/
0x00,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0xFC,0x3F,
0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x00,0x20,0x00,0x00,/*"?",4*/
0x00,0x01,0x80,0x00,0x60,0x00,0xF8,0xFF,0x07,0x00,0x40,0x00,0x30,0x00,0x0F,0x00,
0xF8,0xFF,0x88,0x08,0x88,0x08,0x88,0x08,0x88,0x08,0x08,0x08,0x08,0x00,0x00,0x00,/*"?",5*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
uchar code table2[]=
{
0xfe,0xff,
0xfd,0xff,
0xfb,0xff,
0xf7,0xff,
0xef,0xff,
0xdf,0xff,
0xbf,0xff,
0x7f,0xff,
0xff,0xfe,
0xff,0xfd,
0xff,0xfb,
0xff,0xf7,
0xff,0xef,
0xff,0xdf,
0xff,0xbf,
0xff,0x7f,
};
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
sbit d=P2^5;
sbit jia_key=P3^4;
sbit jian_key=P3^5;
uchar m=15;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void delay1(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=12;y>0;y--);
}
void key()
{
if(jia_key==0) //按键检测处理函数
{
delay(5); //消斗
if(jia_key==0) //按键速度加一
{
m++;
if(jia_key==10)
m==25;
while(jia_key==0);
}
}
if(jian_key==0)
{
delay(5);
if(jian_key==0)
{
m--;
if(jian_key==9)
m=6;
while(jian_key==0);
}
}
}
void main()
{
uint k;
uint i,j,n;
while(1)
{
for(k=0; k<=190; k++)// 平移的行函数 ,多一个字K加15,
{
for(j=m; j>0; j--)//平移的速度
{
for(i=k,n=0;i<k+16; i++,n++)//显示一个16X16的图像
{
//阳极
P1=0x00;
a=1;
P1=table1 [2*i];
a=0;
P1=0x00;
b=1;
P1=table1 [2*i+1];
b=0;
//阴极
P1=0xff;
c=1;
P1=table2 [2*n];
c=0;
P1=0xff;
d=1;
P1=table2 [2*n+1];
d=0;
delay1(5);
c=1;
P1=0xff;
c=0;
d=1;
P1=0xff;
d=0;
}
}
key();
}
if(k>190)
delay(50);
}
}
|