HCMatrixkeypad - Matrix keypad library

Useful guides, libraries, and example sketches to support our Arduino based products.
andrew
Site Admin
Posts: 1384
Joined: Sun Aug 05, 2012 4:15 pm

Re: HCMatrixkeypad - Matrix keypad library

Post by andrew » Sat Oct 15, 2022 10:31 am

All the keys work fine, all RET Values are fine - Except for the VERY FIRST returned Value. The only way I can describe it is for you to PICK any number between 0 & 255 - that is what I get. After that, I get every RET CODE as I should.
T1: Compile using IDE v1.0.6 - RET CODE error does NOT occur; repeat does NOT occur.
T2: Compile using IDE v 1.8.9 - RET CODE error DOES occur; repeat DOES occur.


It sounds like an uninitialised variable somewhere.

I'll see if I can replicate the issue to check if it's a problem with the library or not. Obviously I won't be able to test this on a Windows XP machine but I can at least check the library against those versions of the IDE.

I don't have access to a keypad right now so I probably won't get a chance to test it until I'm back in the office on Monday.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

RetroBoy
Posts: 73
Joined: Sat Feb 26, 2022 11:29 am
Location: U.K.

Re: HCMatrixkeypad - Matrix keypad library

Post by RetroBoy » Sat Oct 15, 2022 3:35 pm

Hi Andrew,

Thanks for the efforts yo are making, very much appreciated.

For what it's worth, please don't keep 'faffing around' with it --- it's not worth it.

All I need to do is remember to just hit 'my' version of Ret Key( # ) then do a reload from EEPROM and everything is back to where it should be.

It really does puzzle me though as to why with v1.06 I don't get the error. If a var is not initialised in v1.0.6 - the same would apply in v1.8.9.

I know many changes in v1.8.9 but the crucial Vars side of things would, or should, be the same.

Anyway, thanks for the efforts ...

Regards S ( P.S: I have PM'd you with the latest code in.zip format )

andrew
Site Admin
Posts: 1384
Joined: Sun Aug 05, 2012 4:15 pm

Re: HCMatrixkeypad - Matrix keypad library

Post by andrew » Mon Oct 17, 2022 9:26 am

Just to follow up on this I've now tested the library with V1.0.6 & V1.8.9 IDEs and in both version the first read code is correct.

I've pasted the test code below which is just a slightly cut down version of the example sketch. So if you're still seeing an issue with the sketch below then you can at least rule out the library as the cause.

  1. #include <HCMatrixKeypad.h>
  2.  
  3. #define DEBOUNCE 10
  4.  
  5. #define PIN_C1 2  /* DIO for keypad column 1 */
  6. #define PIN_C2 3  /* DIO for keypad column 2 */
  7. #define PIN_C3 4  /* DIO for keypad column 3 */
  8. #define PIN_C4 5  /* DIO for keypad column 4. Delete if there is no column 4! */
  9. #define PIN_C5 6  /* DIO for keypad column 5. Delete if there is no column 5! */
  10. #define PIN_C6 7  /* DIO for keypad column 6. Delete if there is no column 6! */
  11.  
  12. #define PIN_R1 12 /* DIO for keypad row 1 */
  13. #define PIN_R2 11 /* DIO for keypad row 2. Delete if there is no row 2! */
  14. #define PIN_R3 10 /* DIO for keypad row 3. Delete if there is no row 3! */
  15. #define PIN_R4 9  /* DIO for keypad row 4. Delete if there is no row 4! */
  16. #define PIN_R5 8  /* DIO for keypad row 5. Delete if there is no row 5! */
  17.  
  18.  
  19. HCMatrixKeypad Keypad(DEBOUNCE, PIN_C1, PIN_C2, PIN_C3, PIN_C4, ROWMARKER, PIN_R1, PIN_R2, PIN_R3, PIN_R4); /* Uncomment for 4x4 keypad */
  20.  
  21.  
  22. void setup()
  23. {
  24.     Serial.begin(9600);
  25. }
  26.  
  27. /* Main program */
  28. void loop()
  29. {
  30.   Keypad.Scan();
  31.  
  32.   if(Keypad.New_Key())
  33.   {
  34.     Serial.println(Keypad.Read()); /* 10's column is the keypad row number */
  35.   }
  36. }

It really does puzzle me though as to why with v1.06 I don't get the error. If a var is not initialised in v1.0.6 - the same would apply in v1.8.9.
It's just a guess. Usually when something is returning random values it either one of 3 things, an uninitialised variable, a physical issue (for instance something that should be connected that isn't, external rf noise, etc), or an array overrun.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “Arduino”