Go Down

Topic: Onewirekeypad (Read 149 times) previous topic - next topic

frank1293

Aug 09, 2016, 06:59 am Last Edit: Aug 09, 2016, 07:06 am by frank1293
Hey all,

I have created my voltage divider for the 4x3 matrix keypad with use of the arduino uno to allow it to use only one analogue pin . Is there any other sample code to output the keypad press onto the serial ? or is that what (Event Key) is meant to do as im not too sure. The only thing running this code gives me is "This is a test" upon pressing the hash key

any help would be awesome cheers

Code: [Select]
//Original Creator: Andrew Mascolo

#include <OnewireKeypad.h>

char KEYS[]= {
  '1','2','3',
  '4','5','6',
  '7','8','9',
  '*','0','#',
};

OnewireKeypad <Print, 12 > Keypad(Serial, KEYS, 4, 3, A15, 4700, 1000 );

void setup ()
{
  Serial.begin(115200);
  pinMode(13,OUTPUT);
  Keypad.addEventKey(test, '#'); // Add Function to list | Key to look for
  Keypad.addEventKey(togglePin13, '*');
}

void loop()
{
  Keypad.ListenforEventKey(); // check if an EventKey is found
}

void test()
{
  Serial.println("This is a test");
  Keypad.deleteEventKey('#'); // remove function from list
}

void togglePin13()
{
  digitalWrite(13,!digitalRead(13));
}

OldSteve

#1
Aug 09, 2016, 08:30 am Last Edit: Aug 09, 2016, 08:31 am by OldSteve
Doesn't it also toggle the onboard LED when '*' is pressed?

I haven't used this method of reading a keypad, but it looks to me like 'getKey()' will return the value of the latest keypress, and probably 0 if there isn't one in the buffer.

Have you tried something like:-
Code: [Select]
char c = getKey();
if(c > 0)
    Serial.println(c);

OneWireKeyPad

Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

Go Up