Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

jumping to another loop by detecting which switch is pressed

Status
Not open for further replies.

McMurry

Member level 3
Joined
Feb 16, 2008
Messages
56
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,746
I have four push up button switch.. each pulled up, and also connected to the PortA 0,1,2,3 respectively.

I am making an infinite loop that will detect if any button switch is pressed, like this:

loop btfss porta,0
goto somewhere
btfss porta,1
goto somewhereelse
.
.
goto loop

However, the code failed to work.

Anyone may help to explain a correct way to do it?
 

Re: jumping to another loop by detecting which switch is pre

you probably need some debouncing done with software. (that is if you are not doing it somehow with hardware)

I am not a PIC guy so I can't help you with your code, HOWEVER, I usually do it this way:

Loop:
check if port0.0 = low, if not go to Next
wait delay 50mS
port0.0 = low, now wait here until its high (button released)
jump to a subroutine

Next:
check if port0.1 = low, if not go to Next1
wait delay 50mS
port0.1 = low, now wait here until its high (button released)
jump to a subroutine

Next1:
check if port0.2 = low, if not go to Next2
wait delay 50mS
port0.2 = low, now wait here until its high (button released)
jump to a subroutine

.
.
.
.
GOTO Loop

if you still can't get it, search Google for "debouncing" or "keypad"
you will get your answer.

Good Luck
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top