这个会压小。看大图到这看
>
要仿真的话我发给你,当然实际电路要三极管驱动
#include <reg52h>
#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,
0xF9,0xEF,0x0F,0xE8,0xF7,0xEF,0x77,0xCF,0x07,0xCF,0xFF,0xEF,0xFF,0xEF,0xFF,0xFF},/"迎",3/
{0xFF,0xFE,0x7F,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,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][a2+1];
a2=~zbm[6][a2];
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++) //显示1616屏幕一次
{
yfs(); //选通显示列 //行选线,P3 低四位
fs (~(zz+FontNum32+(i+row)2+1)); //以移动偏移为基础获取新数据
fs(~(zz+FontNum32+(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);
}
}
数字时钟
这段程序是在PRTUES上完全好使
你可以根据 程序自己在PROTUES上画图
#include<reg51h>
#define uint unsigned int
char code tab[]=;
char code table[]=;
sbit duan=P2^5;
sbit wei=P2^6;
sbit button1=P1^0;
sbit button2=P1^1;
sbit button3=P1^2;
sbit button4=P1^3;
sbit button5=P1^4;
sbit button6=P1^5;
sbit button7=P1^6;
sbit button8=P1^7;
void delay(uint z);
void start();
void display();
static char a,b,c,d,k,e,f,g,h;
static char num1,num2,num3,num4;
void main()
{ start();
while(1)
if(button2==0)
if(button3==0)
if(button4==0)
{ delay(10);
if(button4==0)
}}
while(button4==0)
}
if(button5==0)
{ delay(10);
if(button5==0)
}
while(button5==0)
}
if(button6==0)
{ delay(10);
if(button6==0)
}
while(button6==0)
}
if(button7==0)
{delay(10);
if(button7==0)
{num3--;
if(num3<0)
}
while(button7==0)
}
if(button8==0)
{delay(10);
if(button8==0)
while(button8==0)
}
display();
} }
void start()
{ EA=1;
TMOD=0x01;ET0=1;
TH0=(65536-4000)/256;
TL0=(65536-4000)%256;}
void delay(uint z )
{ uint x,y;
for(x=z;x>0;x--)
for(y=120;y>0;y--);}
void timer1() interrupt 1
{ TH0=(65536-4000)/256;
TL0=(65536-4000)%256;
k++;
if(k==2) //总忘k把清零
{k=0;num1++;
if(num1==100)
{num1=0;num2++;
if(num2==60){num2=0;num3++;
if(num3==60){num3=0;num4++;
if(num4==24)}
}} }}
void display()
{a=num1/10;b=num1%10;c=num2/10;d=num2%10;
e=num3/10;f=num3%10;g=num4/10;h=num4%10;
wei=1;P0=0x80;wei=0;
duan=1;P0=tab[b];duan=0;delay(1);
P0=0x00;
wei=1;P0=0x40;wei=0;
duan=1;P0=tab[a];duan=0;delay(1);
P0=0x00;
wei=1;P0=0x20;wei=0;
duan=1;P0=tab[d];duan=0;
duan=1;P0=table[d];duan=0;delay(1);
P0=0x00;
wei=1;P0=0x10;wei=0;
duan=1;P0=tab[c];duan=0;delay(1);
P0=0x00;
wei=1;P0=0x08;wei=0;
duan=1;P0=table[f];duan=0;delay(1);
duan=1;P0=tab[f];duan=0;delay(1);
P0=0x00;
wei=1;P0=0x04;wei=0;
duan=1;P0=tab[e];duan=0;delay(1);
P0=0x00;
wei=1;P0=0x02;wei=0;
duan=1;P0=tab[h];duan=0;
duan=1;P0=table[h];duan=0;delay(1);
P0=0x00;
wei=1;P0=0x01;wei=0;
duan=1;P0=tab[g];duan=0;delay(1);
P0=0x00;
}
以上就是关于用单片机控制的16x16点阵LED循环显示“北京欢迎你”,这个程序用C语言该怎么写全部的内容,包括:用单片机控制的16x16点阵LED循环显示“北京欢迎你”,这个程序用C语言该怎么写、51单片机多功能LED点阵显示数字时钟、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)