專注電子技術(shù)學(xué)習(xí)與研究
當前位置:單片機教程網(wǎng) >> MCU設(shè)計實例 >> 瀏覽文章

LED點陣模仿舞臺燈光

作者:佚名   來源:本站原創(chuàng)   點擊數(shù):  更新時間:2012年05月11日   【字體:

用的是單色的8*8點陣,行和列分別接在p0和p1口,實現(xiàn)效果比較牛逼.

 
   #include<reg52.h>
   #define  uint unsigned int
   #define  uchar unsigned char
  uchar code LED1[]={0x18,0x3c,0x7e,0xff,0x7e,0x3c}; 
 uchar code LED2[]={0xe7,0xc3,0x81,0,0x81,0xc3,0xe7};
 uchar code su[]={10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,140,130,120,110,100,90,80,70,60,50,40,30,20,};
   void delay(uint z);
   void main()
   {
   uint i=0,j=0; 
   while(1)
   {
   
   if(i==6)
         {   i=0; j++;} 
   P1=LED1[i];
   P0=LED2[i];
   i++;
     delay(su[j]);
     if(j==28)
     j=0;
 }
   }
   void delay(uint z)   //延時函數(shù)
   {
   uint x,y;
   for(x=z;x>0;x--)
   for(y=110;y>0;y--);
   } 
關(guān)閉窗口

相關(guān)文章