单片机控制LED点阵滚动显示:I LOVE YOU

题目要求:

控制LED点阵依次滚动显示出I LOVE YOU,并且滚动速度可控。

仿真电路:
单片机控制LED点阵滚动显示:I LOVE YOU_第1张图片
仿真效果:
单片机控制LED点阵滚动显示:I LOVE YOU_第2张图片

C语言程序代码:

# include 
# define uint unsigned int
# define uchar unsigned char
char code led[]={
	0x0,0x3E,0x8,0x8,0x8,0x8,0x3E,0x0,
	0x0,0x20,0x20,0x20,0x20,0x20,0x3C,0x0,
	0x0,0x38,0x44,0x44,0x44,0x44,0x38,0x0,
	0x4,0x2,0x62,0x22,0x24,0x28,0x10,0x0,
	0x3C,0x20,0x20,0x3C,0x20,0x20,0x3C,0x0,
	0x0,0x44,0x28,0x10,0x10,0x10,0x10,0x10,
	0x0,0x38,0x44,0x44,0x44,0x44,0x38,0x0,
	0x0,0x24,0x24,0x24,0x24,0x24,0x24,0x18
};
         
void delay(uint a)
{
	 uint x,y;
	 for(x=0;x<a;x++)
	 for(y=0;y<110;y++);
}


void main()
{
 uint i,j,k=0,w=0x01;
 while(1)
 {
   for(j=10;j>0;j--)//控制滚动速度
   {
	w=0x01;
     for(i=0;i<8;i++)
     {
       P2=w;
       P3=~led[k+i];
       delay(3);
       w<<=1;
     }
   }
   k++;
   if(k==56)
   {
   k=0;
 }
 }
}


你可能感兴趣的:(单片机,c#)