Hi,
I want to interface a 4x3 keypad to a PIC16F877A. I am connecting to PORT C0-C6. I understand that we need to use some pullup resistors connecting to the rows.
I connect the rows to 10kohms resistor then to the PIC. Is this correct as i have seen various different connections online.
There are no internal pullup's on port C.. so you'll need pullups on each row, the examples on the web are all different as sometimes the reading pins have internal pullps..i.e. portb bits 4 - 7 have internal pullup's on most pic's (also portb usually has interrupt on change, which is handy for a key pad)
There are no internal pullup's on port C.. so you'll need pullups on each row, the examples on the web are all different as sometimes the reading pins have internal pullps..i.e. portb bits 4 - 7 have internal pullup's on most pic's (also portb usually has interrupt on change, which is handy for a key pad)
Hi Ian,
I understand Port B have internal pullups. But i already used Port B for other output functions.
I read through some tutorials and found that the pullup resistors are connected to columns instead. I am getting confused on this. Can you help me understand better?
You only need pullups on the reading pins.. If you connect a keypad to PORTC (loosing a lot of peripherals) and the rows are 0 through 3 and the columns are 4 through 7
TRISC = 0xF0 (reading the top nibble ) You would put a pullup on pins 4,5,6 & 7 then read PORTC and AND 0xF0 whilst setting 0,1,2 & 3 to 0v in turn, while the rest are 5V.
It really doesn't matter what are rows and what are columns as long as you read one line at a time.
You only need pullups on the reading pins.. If you connect a keypad to PORTC (loosing a lot of peripherals) and the rows are 0 through 3 and the columns are 4 through 7
TRISC = 0xF0 (reading the top nibble ) You would put a pullup on pins 4,5,6 & 7 then read PORTC and AND 0xF0 whilst setting 0,1,2 & 3 to 0v in turn, while the rest are 5V.
It really doesn't matter what are rows and what are columns as long as you read one line at a time.
I managed to get the keypad up and display the numbers when pressed the respective numbers.
I have a problem now, as i would need to use the keypad to key in 2 digit numbers and then compare the values with the measured readings from a sensor.
I am unable to display the keyin numbers.
I have a problem now, as i would need to use the keypad to key in 2 digit numbers and then compare the values with the measured readings from a sensor.
I am unable to display the keyin numbers.
If there are only 2 input values its not really that hard. When you read the first digit, save it in a local variable. When the second digit is read, multiply the first by10 and add the second. you then will have a number 0 - 99 that you can compare
If there are only 2 input values its not really that hard. When you read the first digit, save it in a local variable. When the second digit is read, multiply the first by10 and add the second. you then will have a number 0 - 99 that you can compare
Yup. i am done with that portion. I have another question. If i were to use port E of PIC16F877a as output. Do i need to perform any additional codings?
Yup. i am done with that portion. I have another question. If i were to use port E of PIC16F877a as output. Do i need to perform any additional codings?