我想编写16*16点阵的左移程序。用C语言,51单片机。你能否帮我编一个小例程,左移显示“陈”啊?谢谢了~!
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit SH_CP=P2^0;
sbit DS=P2^1;
sbit ST_CP=P2^2;
uchar code tab[ ]=
{
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,/*" ",0*/
0x00,0x00,0x7F,0xFF,0x44,0x40,0x4A,0x20,0x71,0xC4,0x00,0x08,0x23,0x30,0x2D,0x02,
0x31,0x01,0xE7,0xFE,0x21,0x00,0x21,0x40,0x21,0x20,0x21,0x18,0x20,0x0C,0x00,0x00,/*"陈",1*/
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,/*" ",2*/
};
//顺向、逐列、阴码 宋体 MATRIX-8X8-GREEN 左旋90度 左右翻转
// MATRIX-8X8-RED 右旋90度 上下翻转
void delay_ms(unsigned int ms)
{
uchar j;
while(ms--)
for(j=0;j<123;j++);
}
void WriteByte(uchar dat)
{
uchar k;
for(k=0;k<8;k++)
{
dat=dat>>1;
DS=CY;
SH_CP=0;
SH_CP=1;
}
}
void main()
{
uchar num,temp,n,m;
while(1)
{
for(n=0;n<32;n++) //
for(m=0;m<8;m++) //重复显示8次
{
temp=0;// 不加此条,流动飞快
for(num=n;num<16+n;num++)
{
WriteByte(tab[2*num+1]);
WriteByte(tab[2*num+0]);
P1=temp;
ST_CP=0;
ST_CP=1;
delay_ms(1);
temp++;
if(temp==16)
temp=0;
}
}
}
}