flotulopex
- 31st October 2020, 10:59
Hi There,
I'm "reading" a 3x4 keypad matrix and want to show the user he is currently pressing a button.
So I light up a LED while any key is pressed and shut if OFF when the key is released and it works fine.
I'm using this piece of code as a debouncer (that keypad must have yo-yo contacts! :D):
WHILE PORTB.4 = 0 : WEND
WHILE PORTB.5 = 0 : WEND
WHILE PORTB.6 = 0 : WEND
WHILE PORTB.7 = 0 : WEND
Is there a way to make this a little bit better?
I mean, can I read the four ports B and evaluate them at once instead of four lines of code?
I tried several things like
WHILE PORTB & %11110000 = 0 : WEND but I can't get it working :frown:
Any idea how to do this please?
I'm "reading" a 3x4 keypad matrix and want to show the user he is currently pressing a button.
So I light up a LED while any key is pressed and shut if OFF when the key is released and it works fine.
I'm using this piece of code as a debouncer (that keypad must have yo-yo contacts! :D):
WHILE PORTB.4 = 0 : WEND
WHILE PORTB.5 = 0 : WEND
WHILE PORTB.6 = 0 : WEND
WHILE PORTB.7 = 0 : WEND
Is there a way to make this a little bit better?
I mean, can I read the four ports B and evaluate them at once instead of four lines of code?
I tried several things like
WHILE PORTB & %11110000 = 0 : WEND but I can't get it working :frown:
Any idea how to do this please?