用单片机控制的16x16点阵LED循环显示“北京欢迎你”,这个程序用C语言该怎么写 5
这个图片会压小。看大图到这看
http://0e.images22.51img1.com/6000/kgd235143/e4be871c454f0c1d6f7f46b964dacee7.jpg
要仿真的话我发给你,当然实际电路要三极管驱动
#include <reg52.h>
#define uchar unsigned char
uchar i,j,k=15;
sbit xsi=P2^0;
sbit xrck=P2^1;
sbit xsck=P2^2;
sbit ysi=P2^3;
sbit yrck=P2^4;
sbit ysck=P2^5;
sbit kg= P3^2;
uchar code zbm[][32]={
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,},
{0xFF,0xFF,0xFF,0xF7,0xBF,0xF7,0xBF,0xFB,0xBF,0xFD,0x03,0xE0,0xFF,0xFF,0xFF,0xFF,
0x01,0xF0,0x7F,0xEF,0xBF,0xEF,0x9F,0xEF,0xDF,0xEF,0xFF,0xF1,0xFF,0xFF,0xFF,0xFF},/*"北",0*/
{0xF7,0xFF,0xF7,0xFF,0xF7,0xEF,0xF7,0xF3,0x37,0xFF,0xB7,0xFE,0xB6,0xDE,0xD5,0x80,
0xDB,0xFE,0x5B,0xFF,0x9B,0xFB,0xFB,0xF7,0xFB,0xE7,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF},/*"京",1*/
{0xFF,0xEF,0x5F,0xF7,0xDF,0xFA,0xEF,0xFD,0x0F,0xFA,0xFF,0xDF,0xBF,0xEF,0xC7,0xF3,
0x58,0xFC,0xEF,0xFB,0xAF,0xF7,0xCF,0xEF,0xEF,0xCF,0xFF,0xDF,0xFF,0xDF,0xFF,0xFF},/*"欢",2*/
{0xBF,0xF7,0xBF,0xF7,0xBB,0xF6,0x37,0xF1,0xFF,0xF7,0x07,0xF6,0xF7,0xF6,0x7B,0xF7,
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,0x19,0x80,0xBB,0xFD,0xBB,0xFD,0xBF,0xFD,0xFF,0xFD,0xFF,0xFD,0xFF,0xFF},/*"阵",4*/
{0xFF,0xEF,0xFF,0xF7,0xFF,0xF9,0x7F,0xFE,0x81,0xBD,0x75,0xDD,0x65,0xE5,0x55,0xF8},
{0xB6,0xFD,0x9A,0xFD,0x28,0x80,0xBC,0xFE,0xBF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFF},/*"屏",5*/
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,},
};
void ys (uchar a) //延时
{
uchar b;
for (;a>0;a--)
for (b=100;b>0;b--) ;
}
void yfs() //Y轴发数
{
ysck=0;
yrck=0;
k++;
if (k==16)
{
k=0;
ysi=0;
}
else
ysi=1;
ysck=1;
yrck=1;
}
void xfs(uchar a) //X轴发数
{
uchar b,a1,a2;
a1=~zbm[6][a*2+1];
a2=~zbm[6][a*2];
xsck=0;
xrck=0;
for (b=0;b<8;b++)
{
a1=a1<<1;
xsi=CY;
xsck=1;
xsck=0;
}
for (b=0;b<8;b++)
{
a2=a2<<1;
xsi=CY;
xsck=1;
xsck=0;
}
xrck=1;
}
void fs(uchar a) //X轴发数
{
uchar b;
xsck=0;
xrck=0;
for (b=0;b<8;b++)
{
a=a<<1;
xsi=CY;
xsck=1;
xsck=0;
}
xrck=1;
}
void gdhs(uchar *zz,uchar N,uchar Time) //流动显示N个汉字 滚动函数
{ //参数三个:字符串字模首地址、字数、显示流动速度
uchar FontNum,i,j,row; //循环变量,字数计数、16次流动、16列扫描
for(FontNum=0;FontNum<N;FontNum++)
{
for(i=0;i<16;i++) //字到字流动 16次左移才能完成
{
for(j=0;j<Time;j++) //显示延迟,决定流动速度
{
k=15;
for(row=0;row<16;row++) //显示16*16屏幕一次
{
yfs(); //选通显示列 //行选线,P3 低四位
fs (~*(zz+FontNum*32+(i+row)*2+1)); //以移动偏移为基础获取新数据
fs(~*(zz+FontNum*32+(i+row)*2)); //获取显示数据 循环显示关键算法
ys (12); //适当延时
}
}
}
}
}
void wbzd () interrupt 0 //外部中断
{
j++;
if (j>1)
j=0;
ys(10);
while (!kg)
{
k=15;
for (i=0;i<16;i++)
{
yfs();
xfs(i);
ys(10);
}
}
if (j==0)
gdhs(zbm,8,2);
if (j==1)
gdhs(zbm1,10,1);
}
void main ()
{
EA = 1; //打开总中断
EX0=1;
IT0=1;
while (1)
{
if (j==0)
gdhs(zbm,8,5);
if (j==1)
gdhs(zbm1,10,3);
}
}
2023-10-20 广告