Menu

No output on Keypad!!!

Help
Judah Ben
2020-08-17
2020-09-11
  • Judah Ben

    Judah Ben - 2020-08-17

    Please I need some help.

    I am using a 4*4 matrix keypad and I just did the setup on hardware and I need to test if it works but it didn't.

    I used the keypad test code in the keypad solutions folder and edited the ports to mine. I connected pull-ups to my columns also.
    For output, I'm using a 16*4 LCD.

    My rows and columns are not organized due to pin availability. I have them as such:

    Row 1 portd. 7
    Row 2 portd. 6
    Row 3 portd. 5
    Row 4 portd. 4
    Column 1 portc. 5
    Column 2 portc. 4
    Column 3 portd.3
    Column 4 portd.2

    Could that be my problem??

     
  • Anobium

    Anobium - 2020-08-17

    Got some code to share?

     
    • Judah Ben

      Judah Ben - 2020-08-17

      Sorry I couldn't reply in time. I used my phone to make the first post.
      Here's the code....

      'Program to show the value of the last pressed key on the LCD
          #chip 16f877a, 20
      
          'LCD connection settings
          #define LCD_IO 4
          #define LCD_NO_RW
          #define LCD_RS portB.0
          #define LCD_Enable portB.1
          #define LCD_DB4 PortB.2
          #define LCD_DB5 PortB.3
          #define LCD_DB6 PortB.4
          #define LCD_DB7 PortB.5
      
      
          'Keypad connection settings
          #define KEYPAD_ROW_1 portD.7
          #define KEYPAD_ROW_2 portD.6
          #define KEYPAD_ROW_3 portD.5
          #define KEYPAD_ROW_4 portD.4
          #define KEYPAD_COLUMN_1 portC.5
          #define KEYPAD_COLUMN_2 portC.4
          #define KEYPAD_COLUMN_3 portD.3
          #define KEYPAD_COLUMN_4 portD.2
      
      
          'Main loop
          Do
              'Get key
              Temp = KeypadData
      
              'If a key is pressed, then display it
              If Temp <> KEY_NONE Then
                  CLS
                  Print Temp
                  Wait 100 ms
              End If
          Loop
      
       
  • Anobium

    Anobium - 2020-08-18

    OK. That is code that should work.

    Post a photo of the keypad, and, a photo of the setup/connection to the PIC

     
  • Anobium

    Anobium - 2020-08-20

    I am not sure what the issue is. Have you tried on real hardware?

     
    • Judah Ben

      Judah Ben - 2020-08-24

      Yes I have. The behaviour is the same. I'll still have to go over it today to try to figure out if there's an error somewhere.

       
  • stan cartwright

    stan cartwright - 2020-08-24

    Is the problem the keyboard or the display?

     
    • Judah Ben

      Judah Ben - 2020-08-24

      I think it's the keypad.
      The display works fine with displaying whatever I give it in the code.

       
  • mkstevo

    mkstevo - 2020-08-25

    If it's the keypad, shouldn't the Proteus simulation work? On the hardware, it could be that your pullup resistors are too low in value. Have you tried measuring the resistance(s) of the switch buttons when pressed? on some of these carbon print membrane keypads the contact resistance could be quite high, not the near zero ohms you might expect with a traditional switch contact.

     
    • Judah Ben

      Judah Ben - 2020-09-01

      Sorry for this delay. I've been ill for some time.
      I'm not really sure why it isn't working.
      In the simulation, since I couldn't find a 4 by 4 keypad among the component parts, I used a 4 by 3 and then pulled up the empty column. (I thought this would suffice because I saw in the manual where they said if you're using a 3 by 3 keypad, pull up the unused row and column)
      The resistance of each button is roughly 23 ohms.

       
  • stan cartwright

    stan cartwright - 2020-08-25

    You show a photo of a 4x4 keyboard. Why did you not use that as the demos are for 4x4 keyboards?
    would changing c4 and c5 to rd0 and rd1 help?

     
    • Judah Ben

      Judah Ben - 2020-09-01

      Very sorry for the delay.
      I couldn't find a 4 by 4 keypad among the component parts in proteus, I used a 4 by 3 and then pulled up the empty column. (I thought would work, from the manual)
      Okay, let me make the pin changes and get back ASAP

       
      • stan cartwright

        stan cartwright - 2020-09-01

        There are 4 gcb keyboard demos that send to terminal and guess are working but not tried them.

          #chip 16f1938,16
          #option explicit
          #config osc=int
        
        ; ----- Constants
          #define KEYPAD_ROW_1 portb.3
          #define KEYPAD_ROW_2 portb.2
          #define KEYPAD_ROW_3 portb.1
          #define KEYPAD_ROW_4 portb.0
          #define KEYPAD_COL_1 portc.0
          #define KEYPAD_COL_2 portc.1
          #define KEYPAD_COL_3 portc.2
          #define KEYPAD_COL_4 portc.3
        
        ; ----- Define Hardware settings
         ' THIS CONFIG OF THE SERIAL PORT WORKS WITH A  MAX232 (or equiv) THEN TO PC
         ' USART settings - CHANGE PORTS if required
         #define USART_BAUD_RATE 9600
         #define USART_DELAY 5 ms
         #define USART_BLOCKING
         wait 500 ms
        
        
         Dim TEMP as Byte
        
        ; ----- Main body of program commences here.
        
        
          Do
              'Get key
              Temp = KeypadData
              'If a key is pressed, then display it
              If Temp <> KEY_NONE Then
                 HSerPrint Temp
                 'Wait until key is released
                 wait while KeypadData <> KEY_NONE
              End If
          Loop
        

        so I guess this is for a 4x4 keypad cos I can't see where KeypadData is defined or dimmed.
        looks like a keyword for a 4x4 keypad. Dunno.sorry.
        shouldn't make a difference though. maybe you are using wrong port pins.

         

        Last edit: stan cartwright 2020-09-01
  • Judah Ben

    Judah Ben - 2020-09-11

    Thank you very much @evanvennn, @stan, @mkstevo.
    After much trial and error, I changed all the rows and columns of the keypad to a single port (Port D) and used the "Keypad Port" method instead. I changed the LCD screen used and also had to erase the microcontroller before rewriting to it. I think that helped. I can now get input from the keypad to show on the screen.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.