push button with pic16f887

Status
Not open for further replies.

charu2539211

Junior Member level 3
Joined
Jul 22, 2013
Messages
31
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Visit site
Activity points
200
hi

i am using a push button connect to the pic16f887. this is my code in assembly language

i have intialised portd0 as input port and portb as output port.

BANKSEL PORTD
BTFSS PORTD,0
GOTO LEDSEL

;;; delay????;;;
BTFSC PORTD,0
GOTO LEDSEL
GOTO DEC1


LEDSEL
...

DEC1
....

so when i press the push button it should go to DEC1, else it should go to LEDSEL
is my program right???
and do i need to add a delay in between?? if so how much???
 

Your code is not compelete, from what I see, it will run only once and doesn't loop.
Depends on your application, use an interrupt and connect the button to the interrupt pin, or use a loop (resource hogger) if you're connecting it to an IO pin.
Otherwise your code is ok.
 

    V

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…