my project is about a game that turn leds on and off . i have 4 leds and 3 button . i need button one when pressed to turn led 1 and 3 on and when button 2 is pressed turn on led 2 and 4 and finally button 3 turn off the leds.
here i have the code , but when i use it it keep the first the third led on and nothing happen when i press on button 2 or the stop one .
the code :
and the drawing here :
plz help im having it tomor
here i have the code , but when i use it it keep the first the third led on and nothing happen when i press on button 2 or the stop one .
the code :
Rich (BB code):
#INCLUDE "P16F84A.INC"
#DEFINE PB1 PORTB, 1
#DEFINE PB2 PORTB, 2
#DEFINE PB3 PORTA, 3
#DEFINE LEDY PORTA, 0
#DEFINE LEDG PORTA, 1
#DEFINE LEDR PORTA, 2
#DEFINE LEDW PORTA, 3
CBLOCK 0X0C
A1, A2, A3
ENDC
ORG 0X000
GOTO MAIN
MAIN
CALL SETUP
FUNCTION
BTFSC PB1
CALL GAME1
BTFSC PB2
CALL GAME2
BTFSC PB3
CALL STOP
GOTO FUNCTION
STOP
BCF PORTA,0
BCF PORTA,1
BCF PORTA,2
BCF PORTA,3
GAME1
BSF LEDW
CALL DELAY_1S
BCF LEDW
BSF LEDG
CALL DELAY_1S
BCF LEDG
GOTO GAME1
GAME2
BSF LEDR
CALL DELAY_1S
BCF LEDR
BSF LEDY
CALL DELAY_1S
BCF LEDY
GOTO GAME2
DELAY_1S
MOVLW D'46'
MOVWF A1
MOVLW D'189'
MOVWF A2
MOVLW D'37'
MOVWF A3
DECFSZ A3
GOTO $-1
DECFSZ A2
GOTO $-5
DECFSZ A1
GOTO $-9
RETURN
SETUP
CLRF PORTA
CLRF PORTB
BSF STATUS, RP0
CLRF TRISA
MOVLW B'00001110'
MOVWF TRISB
BCF STATUS, RP0
RETURN
END
plz help im having it tomor