访问手机版页面
你的位置:老古开发网 > 其他 > 正文  
流水灯(二)
内容导读:
#include <reg51.h>
void delay(void);
unsigned char string[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void main(void)
{
    unsigned char *p;
 while(1)
 { 
  for(p=string;p<(string+8);p++)
  {
   P1=*p;
   delay();
   }
    P1=0x00;
    delay();
    P1=0xff;
    delay();
    P1=0x00;
    delay();
    P1=0xff;
   for(p=(string+7);p>=string;p--)
   {
    P1=*p;
   delay();
    }
   
    P1=0x00;
    delay();
    P1=0xff;
    delay();
    P1=0x00;
    delay();
    P1=0xff;
   
 
   for(p=string;p<(string+8);p+=2)
  {
   P1=*p;
   delay();
   }
    P1=0x00;
    delay();
    P1=0xff;
    delay();
    P1=0x00;
    delay();
    P1=0xff;
   
     for(p=(string+7);p>=string;p-=2)
   {
    P1=*p;
   delay();
    }
   
    delay();
    P1=0x00;
    P1=0xff;
    delay();
    P1=0x00;
    delay();
    P1=0xff;
 }
 }
 void delay(void)
 {
  int i,j;
 for(i=50;i>0;i--)
  for(j=1000;j>0;j--)
  {;}
  }
标签:
来源: 作者: 时间:2006/9/25 16:50:53
相关阅读
推荐阅读
阅读排行
最近更新
商品推荐