標題: STC15L2K60單片機(beep 數(shù)碼管 按鍵源程序) [打印本頁]

作者: zhaohang20009    時間: 2017-4-6 12:50
標題: STC15L2K60單片機(beep 數(shù)碼管 按鍵源程序)
stc15l2k60綜合驅動
一.秒表+按鍵.hex使用說明:
1. P37接Beep,P36接擴展key
2. 運行后,按鍵1暫停、按鍵2繼續(xù),擴展按鍵清零。
二.綜合驅動工程函數(shù)說明:
1. 音調,用到定時器2
        /*低音1-7*/
        beep_config(1,1);            
        beep_config(2,1);            
        beep_config(3,1);            
        beep_config(4,1);            
        beep_config(5,1);            
        beep_config(6,1);            
        beep_config(7,1);            

        /*中音1-7*/
        beep_config(11,1);        
        beep_config(12,1);        
        beep_config(13,1);        
        beep_config(14,1);        
        beep_config(15,1);        
        beep_config(16,1);        
        beep_config(17,1);        

        /*高音1-7*/
        beep_config(21,1);        
        beep_config(22,1);        
        beep_config(23,1);        
        beep_config(24,1);        
        beep_config(25,1);        
        beep_config(26,1);        
        beep_config(27,1);        
        
        /*關閉聲音1-7*/
        beep_config(1,0);
2.按鍵
讀取按鍵狀態(tài):readkey()
清除按鍵狀態(tài):clrkeystate()
3.數(shù)碼管顯示 ,用到定時器1
填顯示緩沖:digitron_put_buf(num,dat);
顯示數(shù)據(jù),高位滅0,一位小數(shù):dispnum(num)

  1. /**
  2. 最基礎的驅動,配置了按鍵、定時器、蜂鳴器、數(shù)碼管
  3. */

  4. #include        "commoninclude.h"
  5. #include         "ds18b20.h"
  6. #include         "stdio.h"
  7. /**
  8. *  主程序
  9. *  @param  None
  10. *  @return None
  11. */
  12. main(void)
  13. {
  14.         int i;
  15.         TYPEDEF_KEY key;
  16.         unsigned int t,warntemp = 230;
  17.         unsigned char state = 0;
  18.         u16 ad_value, value;
  19.         unsigned char str[20] = {0x00};

  20.         led_config();
  21.         digitron_config();
  22.         key_config();
  23.         beep_pin_config();
  24.         timer_config();
  25.         ds18b20_config();
  26.         ds18b20_start();
  27.         uart_config();        
  28.   adc_config();

  29.         for (i=0;i<8;i++)
  30.         {
  31.                 digitron_put_buf(i,GO_OUT);//顯示緩沖全部滅
  32.         }
  33.         int_enable();        
  34.         while (1)
  35.         {
  36.         }                                

  37. }        

復制代碼



下載:
0.綜合驅動(beep 數(shù)碼管 按鍵).rar (344.71 KB, 下載次數(shù): 16)





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1