Browsing this Thread:
1 Anonymous Users
|
請問儲存控制時間
|
|
中級會員
Joined
: 2004/10/19 11:53 最後登入時間
: 2006/7/5 15:13
Group:
註冊會員
Level : 5 HP : 0 / 122 MP : 16 / 7156 EXP : 90
|
大家好 請問一下 如果要以按鈕的次數來儲存所需要的時間 要如何撰寫 例如每按一次按鈕增加十秒鐘 然後在輸出來控制LED 謝謝
我的程式如下 list p=16F873a #include <p16f873a.inc> ; Include file locate at defult directory ;#define RA4 PORTA,4
VAL_500uS equ .250 ; 0.5ms delay value VAL_1s equ .200 ; 10mS delay value count_1m equ 0x22 count_5s equ 0x23 count_1s equ 0x24 count_us equ 0x25 Reg_time equ 0x26
;********************************************
;********************************************* org 0x00 nop initial:
banksel ADCON1 movlw b'11000110' movwf ADCON1 banksel CMCON movlw b'00000111' movwf CMCON movlw b'00110000' movwf TRISA banksel TRISB ;定義TRISB設定PORTB為輸出模式 clrf TRISB
banksel PORTB clrf PORTB
;*********************************************** Main ;*********************************************** start: clrf Reg_time movlw b'11111111' ;LED初始狀態 movwf PORTB movlw .10 movwf Reg_time
;--------------------------------------------------------
key_time: btfsc PORTA,4 goto add_time btfsc PORTA,5 goto enter_mode goto key_time add_time: movlw .10 addwf Reg_time,1 ;goto key_enter goto key_time
key_enter: btfsc PORTA,5 goto key_time ;goto key_enter goto enter_mode
enter_mode: call delay_1s movlw b'00000000' movwf PORTB decfsz Reg_time goto enter_mode goto clear_mode clear_mode: movlw b'11111111' movwf PORTB goto start
;-----------------------延遲1s------------------------------------------- delay_1s: movlw VAL_1s movwf count_1s loop_1s call delay_0.5ms decfsz count_1s,F goto loop_1s return ;-----------------------延遲0.5ms---------------------------------------- delay_0.5ms: movlw VAL_500uS movwf count_us dec_loop nop nop` nop nop nop decfsz count_us,F goto dec_loop return ;--------------------------------------------------------------------------- end
發表於: 2005/12/21 20:04
|
|
You can view topic.
你 不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.