Vad gör jag för fel?
Postat: 22 februari 2010, 00:06:58
Jag har gjort en kod för att tända och släcka en lampa.
När jag har gjort det 10ggr så skall den behållas tänd.
Som ni märker så är jag nybörjare.
Varför är lampan tänd hela tiden?
Hardware
;*******ingångar
#define HOME TRISA,3 ;Knapp för hemma
input TRISA,3
;*******utgångar
#define VALVE TRISC,0 ;Utgång till ventil
output TRISC,0
bcf VALVE
movlw .10
movwf Flow
;***************************************************************
Program
;*******Vänta på tryckknapp********************
btfss HOME ;tryckknapp=1
;
;*******Tänd lampa*****************************
bsf VALVE ;tänd lampa
;
Call Debounce ;paus
;*******Vänta på tryckknapp********************
;
btfsc HOME ;tryckknap=0
;
Call Debounce ;paus
;
;*******Släck lampa****************************
bcf VALVE ;släck lampa
decfsz Flow ;minska Flow med 1
goto Program
Larm nop
bsf VALVE ;tänd lampa
goto Larm
Debounce
movlw .100
movwf Deb
t1 nop
decfsz Deb,f
goto t1
return
END
När jag har gjort det 10ggr så skall den behållas tänd.
Som ni märker så är jag nybörjare.
Varför är lampan tänd hela tiden?
Hardware
;*******ingångar
#define HOME TRISA,3 ;Knapp för hemma
input TRISA,3
;*******utgångar
#define VALVE TRISC,0 ;Utgång till ventil
output TRISC,0
bcf VALVE
movlw .10
movwf Flow
;***************************************************************
Program
;*******Vänta på tryckknapp********************
btfss HOME ;tryckknapp=1
;
;*******Tänd lampa*****************************
bsf VALVE ;tänd lampa
;
Call Debounce ;paus
;*******Vänta på tryckknapp********************
;
btfsc HOME ;tryckknap=0
;
Call Debounce ;paus
;
;*******Släck lampa****************************
bcf VALVE ;släck lampa
decfsz Flow ;minska Flow med 1
goto Program
Larm nop
bsf VALVE ;tänd lampa
goto Larm
Debounce
movlw .100
movwf Deb
t1 nop
decfsz Deb,f
goto t1
return
END