电工吧
◎ 电工吧 >> 设为首页 >> 加入收藏>> 联系方式 >> 投稿 >>留言 
网站首页 · 电工新闻 · 电工基础 · 电力技术 · 电子技术 · 电工图片 · 电工法规 · 电工图书 · 电工搜索 · 论坛交流
 
      最新电子论文
 · 数码管显示0-9及A-F实验 
 · 稍复杂一点的流水灯电路 
 · 一个简单的流水灯电路及程 
 · 红外感应灯 
 · 微波式感应控制电路 
 · 电容式接近控制电路 
 · 电力线载波通信(LMl893)集 
 · 自制小型程控交换机 
      推荐电子论文

 · 电容式接近控制电路
 · 自己攒,——液晶背投不是梦!
 · 自制超耐用高品质耳机
 · 谈谈电路中的“地”
 · 自制交流自动稳压器
 · 一款典型的立体声功率放大器的

  ■ 所在位置:首页>>电子技术>>电子制作>>正文
 

稍复杂一点的流水灯电路


   LEDIndex = (LEDIndex+1)%16;
}
//Mode 3
void Mode_3(void)
{
 if(LEDDirection)
  LEDShow(~(0x0001< else
  LEDShow(~(0x8000>>LEDIndex));
 if(LEDIndex==15)
  LEDDirection = !LEDDirection;
   LEDIndex = (LEDIndex+1)%16;
}


//Mode 4
void Mode_4(void)
{
 if(LEDDirection)
 {
  if(LEDFlag)
   LEDShow(0xFFFE<     else
   LEDShow(~(0x7FFF>>LEDIndex));
 }
 else
 {
  if(LEDFlag)
   LEDShow(0x7FFF>>LEDIndex);
  else
   LEDShow(~(0xFFFE< }
 if(LEDIndex==15)
 {
  LEDDirection = !LEDDirection;
  if(LEDDirection) LEDFlag = !LEDFlag;
 }
    LEDIndex = (LEDIndex+1)%16;
}


//Mode 5
void Mode_5(void)
{
 if(LEDDirection)
  LEDShow(0x000F< else
  LEDShow(0xF000>>LEDIndex);
 if(LEDIndex==15)
  LEDDirection = !LEDDirection;
    LEDIndex = (LEDIndex+1)%16;
}


//Mode 6
void Mode_6(void)
{
 if(LEDDirection)
  LEDShow(~(0x000F< else
  LEDShow(~(0xF000>>LEDIndex));
 if(LEDIndex==15)
  LEDDirection = !LEDDirection;
    LEDIndex = (LEDIndex+1)%16;
}


//Mode 7
void Mode_7(void)
{
 if(LEDDirection)
  LEDShow(0x003F< else
  LEDShow(0xFC00>>LEDIndex);
 if(LEDIndex==9)
  LEDDirection = !LEDDirection;
    LEDIndex = (LEDIndex+1)%10;
}


//Mode 8
void Mode_8(void)
{
 LEDShow(++LEDIndex);
}


void TimerEventRun(void)
{
 if(RunMode==0x00)
 {
  Mode_0(); 
 }
 else if(RunMode ==0x01)
 {
  Mode_1();
 }
 else if(RunMode ==0x02)
 {
  Mode_2();
 }
 else if(RunMode ==0x03)
 {
  Mode_3();
 }
 else if(RunMode ==0x04)
 {
  Mode_4();
 }
 else if(RunMode ==0x05)
 {
  Mode_5();
 }
 else if(RunMode ==0x06)
 {
  Mode_6();
 }
 else if(RunMode ==0x07)
 {
  Mode_7();
 }
 else if(RunMode ==0x08)
 {
  Mode_8();
 }
}


void Timer2(void) interrupt 5 using 3
{
 TF2 = 0;  //中断标志清除( Timer2 必须软件清标志!)
 if(++TimerCount>=SystemSpeed)
 {
  TimerCount = 0;
  TimerEventRun();
    }
}
unsigned char MusicIndex = 0;
void KeyDispose(unsigned char Key)
{
 if(Key&0x01)
 {
  LEDDirection = 1;
  LEDIndex = 0;
  LEDFlag = 1;
  RunMode = (RunMode+1)%9;
  Display(RunMode);
 }
 if(Key&0x02)
 {
  if(SystemSpeedIndex>0)
  {
   --SystemSpeedIndex;
   SetSpeed(SystemSpeedIndex);
  }
  else
  {
   LEDFlash(6);
  }
 }
 if(Key&0x04)
 {
  if(SystemSpeedIndex<28)
  {
   ++SystemSpeedIndex;

本新闻共3页,当前在第2页  [1]  [2]  [3]  

 
         相关文章

·
·

 
 
  关于本站 | 友情站点 | 联系方式 | 版权声明 | 电工技术服务与支持中心
Copyright© 2005-2006 Dg8.Com.CN ,All Rights Reserved
电工网 电工吧 电子吧