色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          LED流星雨C51程序

          作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
          P1口上接8個led燈可以實現(xiàn)流星雨效果,測試成功.

          #include
          #define uchar unsigned char
          #define led P1
          bit flag=0;
          uchar code lshift[3]={0x07,0x03,0x01};
          uchar code shift[7]={0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe};
          //imitate PWM data
          uchar code sta0[100]={ 0x0f,0x8f,0x8f,0x8f,0x8f,0x8f,0x8f,0x8f,0x8f,0x8f,
          0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,
          0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,
          0xcf,0xcf,0xcf,0xef,0xef,0xef,0xef,0xef,0xef,0xef,
          0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,
          0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,
          0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,
          0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,
          0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,
          0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef,0xef
          };
          //functions statement
          void delay(uchar ms);
          uchar exchg(uchar dat);
          //main function
          void main()
          {
          uchar i,j,k,x,sdata;
          while(1)
          {
          for(k=1;k<8;k++)
          for(i=0;i<22;i++)
          for(j=0;j<100;j++)
          {
          sdata=(sta0[j]>>k)|shift[k-1];
          if(flag==1) led=exchg(sdata);
          else led=sdata;
          }
          for(x=1;x<4;x++)
          for(i=0;i<22;i++)
          for(j=0;j<100;j++)
          {
          sdata=( sta0[j]<<(4-x) )|lshift[x-1];
          if(flag==1) led=exchg(sdata);
          else led=sdata;
          }


          }
          }
          void delay(uchar ms)
          {
          uchar n;
          while(ms--)
          {
          for(n=125;n>0;n--);
          }
          }
          uchar exchg(uchar dat) //對字節(jié)的高位和低位進行互換!
          {
          uchar temp;
          temp=
          ((dat&0x01)<<7)|
          ((dat&0x02)<<5)|
          ((dat&0x04)<<3)|
          ((dat&0x08)<<1)|
          ((dat&0x10)>>1)|
          ((dat&0x20)>>3)|
          ((dat&0x40)>>5)|
          ((dat&0x80)>>7);
          return temp;
          }

          本文引用地址:http://cafeforensic.com/article/201611/323367.htm


          關(guān)鍵詞: LED流星雨C51程

          評論


          技術(shù)專區(qū)

          關(guān)閉