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.

4X1 Keypad not working

Status
Not open for further replies.
Joined
Apr 8, 2012
Messages
201
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Activity points
0
I've connected a 4X1 keypad to pic16f877a and enabled the internal pullups.
But the keypad refuses to work. If I make the keypad 4X3 or 4X4 it works without any problem. What might be the problem? Should I disable Comparators? If yes what is the Command to disable it, like CMCON = 0... Also want to set PORTB and PORTD as digital I/O. What is the command for it. I am using porta pins for adc measurement.

my settings are

ADCON0 = 0b00001111;
ADCON1 = 0b00000000;
CMCON = 0;
TRISC = 0b00000000;
TRISA = 0b00001111;
TRISB = 0b11111111;
TRISD = 0b00000000;
OPTION_REG.B7 = 0;
 

4 x 1 keypad is just using 4 pins for input ..
do you mean you are not able to read pin high/low :roll:
what pins do you use for keypad .. what does comparator have to do with this ..
 

I think problem is in schematics not in sw....?!
Can you give us circuite?
 

I think problem is in schematics not in sw....?!
Can you give us circuite?

Here is the schematics.
 

Attachments

  • scheme_keypad4x4.gif
    scheme_keypad4x4.gif
    66.1 KB · Views: 51
  • 4x1_keypad_portb.bmp
    341.6 KB · Views: 29

The schematics show a 4x4 keypad which you say is working ..
what way do you interface a 4x1 keypad

do you make any changes in software for 4x1 keypad
would also need to have a look at software to verify
you could use a 2x2 keyboard also
or also 4 push buttons on 4 pins if you need 4 pins only
 

The schematics show a 4x4 keypad which you say is working ..
what way do you interface a 4x1 keypad

do you make any changes in software for 4x1 keypad
would also need to have a look at software to verify
you could use a 2x2 keyboard also
or also 4 push buttons on 4 pins if you need 4 pins only

I need a 4x1 keypad with internal pullups on portb of pic16f877a enabled
RB0 goes to SW1 ROW1
RB1 goes to SW2 ROW1
RB2 goes to SW3 ROW1
RB3 goes to SW4 ROW 1
COLOUMN goes to RB4

with internal pull ups enabled all pins will be high without switches pressed.
with SW1 pressed RB0 and RB4 goes 0
with SW2 pressed RB1 and RB4 goes 0
with SW3 pressed RB2 and RB4 goes 0
with SW4 pressed RB3 and RB4 goes 0

i will scan for portb = 0b11110110 for SW1 pressed
portb = 0b11110010 for SW2 pressed
portb = 0b11110100 for SW3 pressed
portb = 0b11111000 for SW4 pressed

and perform the necessary actions.
 

Here lies the error .. did you define RB4 as output and drive RB4 low
actually you donot need RB4 line .. simply connect the column to GND and you can use the reading scheme you mentioned before
 

Here lies the error .. did you define RB4 as output and drive RB4 low
actually you donot need RB4 line .. simply connect the column to GND and you can use the reading scheme you mentioned before

No. I didn't define RB4 as Output. Should I set TRISB = 0b00001111. But I think with internal pull ups enabled all pins will be i/p.

Should I scan for portb = 0b00000001, 00000010, 00000100, and 00001000?

I've changed the schematic. I've attached the new one. I've connected sSWs to +5V.
 

Attachments

  • 4keys.bmp
    431.3 KB · Views: 33
Last edited:

yes .. you should define RB4 as output
and instead of looking for the entire port .. test for a particular pin .. if it is high or low
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top