Reputation: 11
I am using PIC16F882 (28 pins) microcontroller.
I have the hardware in which 4 digit seven segment (common anode & connected by 4 transistor via PORT B1 TO B4) and 8 buttons normal keypad in connected to single PORT pins (PORT C). Now i am able to run 4 digit seven segment without using any buttons. I have to write a code in which when i press a button the display should turn on and show some value.
Now my problem is that, to recognize the keypad i have to set (initialize) the port pins as input and to place value in display i have to set the port (initialize) pins as output. So how can i operate display along with the keypad that are connected to the same port.
I tried to scan keypad and display one by one for 1ms but keypad is not working (controller is not able to recognize a key press). Doing this scanning process when i see the voltage at any key i found floating value of 1.56 V & 2.65 V (Without pressing key) No change in voltage when i press a key.
I don't know what should i do? I need some idea or concept which i can try to implement. Please Help.
Thanks in advance.
Upvotes: 0
Views: 1308
Reputation: 137
I think you better use a chip which has more ports for your project (say pic16F877) so that you can have the 7 segment display on 1 port (portB) and the other port (portC) to turn on/off the segment that you like. PortD used for keypad. If you use separate port like I mentioned above, it saves a lot of your time when you have to look at your circuit as well as the code. You can have a look at this link below from Trini Robotics to see how they control the 7 Segment Display: http://trinirobotics.com/?p=652
Upvotes: 0