中文字幕无码不卡一区二区三区_少妇被又大又粗又爽毛片久久黑人_91精品国产在热久久无毒不卡_久久久久久亚洲综合网站

技術(shù)熱線: 4007-888-234
設(shè)計開發(fā)

專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命

開發(fā)工具

提供開發(fā)工具、應用測試 完善的開發(fā)代碼案例庫分享

技術(shù)支持

從全面的產(chǎn)品導入到強大技術(shù)支援服務 全程貼心伴隨服務,創(chuàng)造無限潛能!

新品推廣

提供新的芯片及解決方案,提升客戶產(chǎn)品競爭力

新聞中心

提供最新的單片機資訊,行業(yè)消息以及公司新聞動態(tài)

漸明漸暗動態(tài)流水燈效果(C源程序)

更新時間: 2019-03-25
閱讀量:237

//--------------------------------------------------------
//項目: 燈閃控制
//設(shè)計: 程序匠人
//--------------------------------------------------------
/*
匠人按:一般的流水燈,LED都是固定亮度的。本程序在此基礎(chǔ)上,實現(xiàn)漸明漸暗的效果。原理就是采用軟件實現(xiàn)PWM,通過調(diào)節(jié)每個LED的亮滅時間比(占空比)來調(diào)節(jié)LED的亮度。本程序在EDN提供的51助學板上測試通過。
*/
//--------------------------------------------------------
/*
版本說明:
程序01_P0口燈閃_V01: 2008-5-21 22:53
 8個LED一起閃爍

程序01_P0口燈閃_V02: 2008-5-21 22:53
 8個LED流水燈

程序01_P0口燈閃_V03: 2008-5-22 21:36
 仍舊是8個LED流水燈,規(guī)范程序

程序01_P0口燈閃_V05: 2008-5-22 23:19
 漸明漸暗動態(tài)流水燈效果

*/
//--------------------------------------------------------
//插入文件包
//--------------------------------------------------------
#include   //加入頭文件;

//--------------------------------------------------------
//重新命名數(shù)據(jù)類型
//--------------------------------------------------------
typedef unsigned char tU08;   //unsigned 8 bit definition
typedef unsigned char tU8;   //unsigned 8 bit definition
typedef unsigned int tU16;   //unsigned 16 bit definition
typedef unsigned long tU32;   //unsigned 32 bit definition

typedef signed char tS08;   //signed 8 bit definition
typedef signed char tS8;   //signed 8 bit definition
typedef signed int tS16;   //signed 16 bit definition
typedef signed long tS32;   //signed 32 bit definition

typedef float tF32;

//--------------------------------------------------------
//--------------------------------------------------------

#define LED_ON 0  //LED點亮
#define LED_OFF 1  //LED熄滅

/*
//--------------------------------------------------------
//延時子程序
//--------------------------------------------------------
void delay(tU16 a)    
{
 tU16 b;    
 for(b=0;b}
*/

//--------------------------------------------------------
//主函數(shù)
//--------------------------------------------------------
void main()     
{
 tU08 i,j ;

 tU08 t_jsq ;  //周期計數(shù)器(范圍0~199)

 tU08 duty_led0 ; //LED0的占空(范圍0~200;數(shù)值越大,LED越亮;下同)
 tU08 duty_led1 ; //LED1的占空
 tU08 duty_led2 ; //LED2的占空
 tU08 duty_led3 ; //LED3的占空
 tU08 duty_led4 ; //LED4的占空
 tU08 duty_led5 ; //LED5的占空
 tU08 duty_led6 ; //LED6的占空
 tU08 duty_led7 ; //LED7的占空

tU08 duty_led_buf0 ; //緩沖
 tU08 duty_led_buf1 ; //緩沖
 tU08 duty_led_buf2 ; //緩沖
 tU08 duty_led_buf3 ; //緩沖
 tU08 duty_led_buf4 ; //緩沖
 tU08 duty_led_buf5 ; //緩沖
 tU08 duty_led_buf6 ; //緩沖
 tU08 duty_led_buf7 ; //緩沖


 while(1)     //無限循環(huán)
 {
  duty_led0 = 0 ;
  duty_led1 = 0 ;
  duty_led2 = 0 ;
  duty_led3 = 0 ;
  duty_led4 = 0 ;
  duty_led5 = 0 ;
  duty_led6 = 0 ;
  duty_led7 = 0 ;

  duty_led_buf0 = 1 ;
  duty_led_buf1 = 2 ;


duty_led_buf2 = 4 ;
  duty_led_buf3 = 200 ;
  duty_led_buf4 = 4 ;
  duty_led_buf5 = 2 ;
  duty_led_buf6 = 1 ;
  duty_led_buf7 = 0 ;


  //P1_0 = LED_ON ;
  //P1_1 = LED_ON ;
  //P1_2 = LED_ON ;
  //P1_3 = LED_ON ;

  for ( j = 0 ; j<50 ; j++ )  //調(diào)節(jié)流水燈間隔時間
  {


   for ( i = 0 ; i<5 ; i++ )  //調(diào)節(jié)流水燈速度
   {

  //根據(jù)占空比,控制每個LED的亮度
    for ( t_jsq = 0 ; t_jsq <200  ; t_jsq ++ )
    {
     if ( t_jsq < duty_led0 ) P0_0 = LED_ON ; else P0_0 = LED_OFF ;
     if ( t_jsq < duty_led1 ) P0_1 = LED_ON ; else P0_1 = LED_OFF ;
     if ( t_jsq < duty_led2 ) P0_2 = LED_ON ; else P0_2 = LED_OFF ;
     if ( t_jsq < duty_led3 ) P0_3 = LED_ON ; else P0_3 = LED_OFF ;
     if ( t_jsq < duty_led4 ) P0_4 = LED_ON ; else P0_4 = LED_OFF ;
     if ( t_jsq < duty_led5 ) P0_5 = LED_ON ; else P0_5 = LED_OFF ;
     if ( t_jsq < duty_led6 ) P0_6 = LED_ON ; else P0_6 = LED_OFF ;
     if ( t_jsq < duty_led7 ) P0_7 = LED_ON ; else P0_7 = LED_OFF ;

    } 
   }

   //占空隊列移動
   duty_led0 = duty_led1 ;
   duty_led1 = duty_led2 ;
   duty_led2 = duty_led3 ;
   duty_led3 = duty_led4 ;
   duty_led4 = duty_led5 ;

 duty_led5 = duty_led6 ;
   duty_led6 = duty_led7 ;
   duty_led7 = duty_led_buf0 ;
   duty_led_buf0 = duty_led_buf1 ;
   duty_led_buf1 = duty_led_buf2 ;
   duty_led_buf2 = duty_led_buf3 ;
   duty_led_buf3 = duty_led_buf4 ;
   duty_led_buf4 = duty_led_buf5 ;
   duty_led_buf5 = duty_led_buf6 ;
   duty_led_buf6 = duty_led_buf7 ;
   duty_led_buf7 = 0 ;
  }

  //delay(65535);   //延時

//--------------------------------------------------------
//
// THE END

 



西宁市| 六盘水市| 山阴县| 渭南市| 曲松县| 沈丘县| 平昌县| 汾阳市| 郧西县| 林甸县| 望江县| 宁德市| 喀喇| 静安区| 鹿邑县| 泽州县| 眉山市| 镇雄县| 佛学| 多伦县| 泸定县| 乡城县| 华坪县| 岑巩县| 民权县| 曲阳县| 班玛县| 呼和浩特市| 赞皇县| 大埔县| 遂平县| 西平县| 云龙县| 绍兴县| 社旗县| 五华县| 渭南市| 寿宁县| 淮阳县| 扬中市| 资阳市|