×
嵌入式 > 技术百科 > 详情

[C51代码]广告灯的循环移动

发布时间:2020-06-04 发布时间:
|
#include

/************************************************/
sbit Key=P2^0;
static unsigned char p=0;

void delay1ms(unsigned int count)
{
  int x,y;
  for(x=0;x   for(y=0;y<120;y++);
}
/************************************************/
void ScanKey()
{  
   if(Key==0) 
  {
    delay1ms(1);
 if(Key==0)
 {
   p++;
   if(p==8) p=0;
 }
   while(Key==0);   //按键锁定,每次按键只加1
  } 
}
/************************************************/
void main()
{
   unsigned char i;
   unsigned char a,b;
   unsigned char temp=0x0f;
   while(1)
  {  ScanKey();
     for(i=0;i<8;i++)
    {
     a=temp<

  b=temp>>(8-p);
  P0=a|b; 
    }
   }
}
 

『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
SN74LVC04AD的技术参数