Giter Club home page Giter Club logo

keypad's People

Contributors

chris--a avatar paulstoffregen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keypad's Issues

Keypad library does not work with Pro Trinket

When using the Keypad library on a Pro Trinket 3v, erratic results occur (mainly: led #13 is dimly lit and code does not function as expected). Code is a slight modification of the example given on the Adafruit website. I have narrowed the problem down to the getKey() function call. Exact code runs flawlessly on a Leonardo board. My apologies if this is not the correct channel to bring this to your attention. Would you have a suggestion? Many thanks!
keypadsa.zip

Column3 recognized as Column1, too (Column-Order)

If i use the column in ascending order the column3 will be recognized as Cloumn1, too.
In Descending Order it works fine. I used it with Arduino Uno (Actual GUI 1.8.5)

Wont work:
byte colPins[COLS] = {2, 3, 4};

Will work:
byte colPins[COLS] = {4, 3, 2};

My config for the rows:
byte rowPins[ROWS] = {5, 6, 7, 8};

Is this a bug?
What am i doing wrong?

Enhancement proposal

Hi,
For my project, I had to modify this lib to comply to my need : being able to avoid short press event (PRESSED) before receiving the long press event (HOLD).
It's like when you double click with the mouse, you don't want your first click to be interpreted as a single click.
Are you interested by this change ? It does not break current way of working, it just add 2 new event types : RELEASED_PRESSED and RELEASED_HOLD.

If yes let me know how I should proceed to propose it (I have never uploaded to GitHub).
jy :)

The readings are unstable on the Uno R4 board.

Has anyone tried using this library on the Uno R4 board? I attempted to use the code below, but the data obtained was very unstable and the serial monitor kept printing 1. Although there was a response when pressing the button, it cannot be used for practical applications on the R4 board.

// Include the Keypad library
#include <Keypad.h>

// Define the number of rows and columns in the keypad
const byte ROWS = 4;
const byte COLS = 4;

// Define the keys on the keypad
char keys[ROWS][COLS] = {
  { '1', '2', '3', 'A' },
  { '4', '5', '6', 'B' },
  { '7', '8', '9', 'C' },
  { '*', '0', '#', 'D' }
};

// Define the pins connected to the rows and columns of the keypad

byte rowPins[ROWS] = { 9, 8, 7, 6 };
byte colPins[COLS] = { 5, 4, 3, 2 };



//Create an object of keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup() {
  Serial.begin(9600);
}

void loop() {
  char key = keypad.getKey();  // Read the key

  // If a key is pressed, print the key on the serial monitor
  if (key) {
    Serial.print("Key Pressed : ");
    Serial.println(key);
  }
}

image

This library is incompatible with Raspberry Pi Pico (W)

As mentioned in previous issue, the macro added into Keypad.h is not working properly with INPUT_PULLUP mode - I made a test with Raspberry Pico W board.
Please update library by removing this section (lines 38-54).
Thank you in advance!

Use `const` for constructor's arguments..

It is better to change this line to:
Keypad(const char *userKeymap, const uint8_t *row, const uint8_t *col, uint8_t numRows, uint8_t numCols);

So the code can support:

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

const uint8_t COLUMN_PINS[] = {9, 8, 7, 6};
const uint8_t ROW_PINS[] = {5, 4, 3, 2};

Keypad keypad = Keypad(KEYS, COLUMN_PINS, ROW_PINS, sizeof(ROW_PINS), sizeof(COLUMN_PINS));

Keypad.h and ESP8266WiFi.h not cooperating

Hello,
I am currently trying to use ESP-now to connect a keypad unit and reciever unit, but as soon as I import both libraries into the same sketch and try to compile it (in Arduino IDE), multiple error messages are shown.
Some of them complain about expansion of macros (like for example: "wl_definitions.h:73:3: note: in expansion of macro 'CLOSED' CLOSED = 0,")
Other say "... ESP8266WiFi.h:29:1: error: expected declaration before '}' token }" mentioning all different ESP8266 libraries.
Do you have any idea, where is the problem and how to solve it?
Thank you in advance.

hello, I need a solution

what if I make a device with a keypad and if the keypad is pressed it will write data and data will be stored in the Arduino data will appear in the serial monitor when connected to the laptop. The data will be deleted when the button is pressed

Keypad does not register as keyboard in Mac OSX Sierra

Hey there!

I've been playing around with this library for a bit - awesome stuff! I use it with a PC on Windows 10, and it's flawless.

I'm trying to use it on Mac OSX Sierra with Karabiner Elements (for cool macros), and it's having some problems registering keystrokes (specifically it won't register modifiers from other boards and vice versa). The board I made registers on Sierra as some kind of all-purpose device (not just a keyboard), and I think that's the cause of my problem.

Any ideas on how I could get my project to register as a traditional keyboard? Retroactive thanks for making this cool code, and pre-thanks for any feedback!

screen shot 2017-02-13 at 3 39 41 pm

Bigger size matrix - 25 x 25

Hi

I want to interface a 25 x 25 keypad matrix with arduino. Is there any way I can do the same? Also how to increase the keymap characters above 255 values? Can we use hex values for mapping the keys of the keypad matrix?
Please suggest.

Does not work on the Nano 33 IOT

This works great for my Uno, standard Nano, and Mega Arduinos. Trying this on a nano 33 iot and it results in a string of 1's on the seral terminal. Hitting a key results in a response of the first column of that row (if I hit 5 I get a 4, a 0 gets a *, etc). There is a note that libraries need to be updated for the nano 33 iot in the forums. Will this library be updated or is there a suggested replacement?

Support to STM32F103C8T6

Hello, I would like to know if it is possible for this library to work with the stm32f103c8t6 cards, currently when I try to compile I get an error, and I can not change the library to work.

Max number of characters in key name

In the keymap if I name a key using a phrase more than one character long, when I view the output in the serial viewer it only shows the last letter of the key's name every time it is pressed. Is this an issue or am I doing something wrong? Help!

change constructor prototype to allow const pin arrays

It's annoying to not be able to declare the rows and cols pins or the keys as const without having a compile time warning.

Please change the constructor prototype to document the fact that you are not messing around with the arrays and thus they can be const.

please go for:

Keypad::Keypad(const char *userKeymap, const byte *row, const byte *col, byte numRows, byte numCols)

SetDebounceTime, SetHoldTime bugs

In Keypad.cpp, method SetDebounceTime have argument debounce which is unsigned int. If we pass -1 for example debounce will have value 65535, because of nature of unsigned int type (https://www.arduino.cc/en/Reference/UnsignedInt). So if ( debounce < 1 ) { debounceTime = 1;} will never be reached in code and keypad will become unstable. This also happens in SetHoldTime method!

void Keypad::setDebounceTime(uint debounce) {
debounce<1 ? debounceTime=1 : debounceTime=debounce;
}

Solution idea:

define MAX_DEBOUNCE_VALUE 255

void Keypad::setDebounceTime(uint debounce) {
if( debounce > MAX_DEBOUNCE_VALUE )
{
debounceTime = MAX_DEBOUNCE_VALUE;
}
else
{
debounceTime = debounce;
}
}

Now if debounce ≥ 0 && debounce ≤ MAX_DEBOUNCE_VALUE
debounceTime = debounce
else
debounceTime = MAX_DEBOUNCE_VALUE

Using analog A6, A7 on Arduino Nano

The specification says that A6, A7 on Arduino Nano can only be used for analog inputs. Indeed, when I (not reading thoroughly the ATMEL spec) used A6, A7 as rows in Keypad setup, the whole sketch stopped to work (even reading from read digital inputs).

However if the HW provides pull-up resistors, even A6, A7 can be used as rows in the keypad matrix input, at the cost of some ifs in pin_mode etc. I'll prepare subclass of Keypad to allow for processing analog inputs.

Library conflict-GSM-Keypad, still needs to be fixed! #4858

Take a blank Arduino sketch, include and . try to compile. I receive this error:
"C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3MobileAccessProvider.h:37:36: note: previous declaration 'GSM3_NetworkStatus_t IDLE'
enum GSM3_NetworkStatus_t { ERROR, IDLE, CONNECTING, GSM_READY, GPRS_READY, TRANSPARENT_CONNECTED, OFF};"

Researching this, I see many years of users asking that this be fixed, and not expecting to be told
fix it yourself by editing a library. What then for the next release, fix it again?
I've already check the forum and the issues. Many 'smart alecs' say its fixed, where?
This happens in v1.6.5, 1.6.6, and in (.org's) 1.7.9.

When will Arduino.cc fix this?

And, yes, I'm a newbie. So if I'm expecting too much or have entered the lib names incorrectly,
let me know.
Doug

Example for 4x4 keypad (0~9 + A, B, C, D)

If someone needs to use a 4x4 keypad of this model of the image, can try with this configuration:

keypad 4x4

const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad

Max number of rows and colums

I have an old commodore keyboard with 8 rows and 16 cols. I adjusted the example sketch but keypresses are not detected at all.
I wonder if there is a maximum amount of cols and rows supported by the keypad library.
Especially this line from keypad.h seems to define a hard limitation.

#define MAPSIZE 10 // MAPSIZE is the number of rows (times 16 columns)

RaspberryPi Pico - adding library kills I/O pullups

I have a raspberryPi Pico (based on RP2040), and when I just include the library (i.e. don't reference any functions or define any I/O's), I/O that have been defined as pull-ups no longer have a pull-up
for example
in setup(), I have
pinMode(14, INPUT_PULLUP);

So, before adding #include <keypad.h>
GP14 reads a steady 3.2v with a multimeter
after adding just #include <keypad.h>
GP14 now reads a varying value around 140mV

It's affecting the actual pins for the key matrix, as I first noticed that when I had the full code for one of the examples, just touching the pins caused key presses to be registered - a sure sign of lack of pull-ups

I don't understand why it should be affecting other IO pins not used by the keypad library, but it seems to affect them all
I realise I could add pullups to the actual kaypad matrix, but more worried that it affects other pins that I intend to use for other features that rely on internal pullups working

My apologies if I've missed something obvious

I'm using PlatformIO inside VSCode if that makes any difference
and have
lib_deps = chris--a/Keypad@^3.1.1 in platformio.ini

My entire program is below, with the majority commented out

#include <Arduino.h>
#include <Keypad.h>

/*
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[ROWS] = {6, 7, 8, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {10, 11, 12}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
*/

void setup(){
  Serial.begin(115200);
    pinMode(14, INPUT_PULLUP);
    pinMode(15, INPUT_PULLUP);
}

void loop(){
/*
  char key = keypad.getKey();

  if (key != NO_KEY){
    Serial.println(key);
  }

  */
}

Don't #define OPEN and CLOSED

In Keypad.h the following macros are defined

#define OPEN LOW
#define CLOSED HIGH

Because of this, any code that includes Keypad.h can't use OPEN or CLOSE for enum names. E.g.

  enum ActuatorStatus
  {
    CLOSED,
    OPEN,
    CLOSING,
    OPENING,
    TIMEOUT,
    ERROR = -1
  };

image

In addition, these #defines are duplicated in Key.h.

Super annoying.

One way to fix this is to delete the #defines from Keypad.h and replace the ones in Key.h with:

#define __OPEN LOW
#define __CLOSED HIGH

or, even better:

enum ButtonState {
   OPEN = LOW,
   CLOSED = HIGH
};

Or something similar.

Multi-keypress require diodes?

I want too use multi-keypress……but i got a ghosting key problem.
May be add diodes is the only way too solved it?
But what the positon should the diodes be installed?
It should toward the row ?or the column?

Compatibility issue with STM32 and Arduino 1.8.5

while compiling it exits with,

exit status 1
Error compiling for board Maple Mini.

using STM32 (Maple Mini board) & Arduino 1.8.5

It would be great if you could fix the compatibility issue.

details are as :

/Keypad.h:50:22: error: invalid conversion from 'byte {aka unsigned char}' to 'WiringPinMode' [-fpermissive]
pinMode(_pin, _mode);
/Keypad.h:43:30: note: in expansion of macro '_mypinMode'
#define pinMode(_pin, _mode) _mypinMode(_pin, _mode)
Keypad.h:80:50: note: in expansion of macro 'pinMode'
virtual void pin_mode(byte pinNum, byte mode) { pinMode(pinNum, mode); }
In file included from C:\Users\Niraj\Documents\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/wirish.h:55:0,
from C:\Users\Niraj\Documents\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/Arduino.h:30,
from sketch\stm32_06_kb_01.ino.cpp:1:
C:\Users\Niraj\Documents\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/io.h:110:6: error: initializing argument 2 of 'void pinMode(uint8, WiringPinMode)' [-fpermissive]
void pinMode(uint8 pin, WiringPinMode mode);

won't add to the library

Hey my friend. i hoped you could help me out, with why arduino doesn't wanna add the files to library. It is in dansih, but it just says that "Keypad-mester" can't be used and that it has to be ascii? even though it is.
i have done it before in sketch and then "add library", but it won't with any zip file. I would really appreicate if you can help out! I have removed the second include "Keypad.h" still doesn't help ;)
keypad library

Avoid nonClick event

Hello, I've build an application using keypad and mount it inside a box. From time to time I receive a beep indicating a fail click in the matrix pad. In other words, there are some interference that I can't understand why. I've tried increasing debounce time. It get better, but still a problem from time to time. Can anyone point a way to improve my code?

It always detect "1" as button pressed.

#include <Arduino.h>
#include <Keypad.h>
#include <UIPEthernet.h>

#define CLIENT_ID "Pad-Senha"
#define RESET_DELAY   5000
#define TEMPO_PREALARME 2000

void buttonPress();
void resetBeep();
void passOk();
void sendMessage(char[]);
void checkMessage();

const uint password_1 = 123; // change your password here
const uint password_2 = 456;  // change your password here
const uint password_3 = 789;   // change your password here
const uint password_4 = 012;   // change your password here
const uint password_5 = 345;   // change your password here
String input_password;

long previousMillis;
long tempoprealarme;

byte start_timer = 0;

byte alarme = 0;
byte prealarme = 0;
byte alarme_sirene = 1;

const int BUZZER_PIN = 9;
const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 3; //three columns

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

byte pin_rows[ROW_NUM] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {6, 7, 8}; //connect to the column pinouts of the keypad
byte i;

Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );

EthernetUDP udp;

void setup(){
  pinMode(BUZZER_PIN,OUTPUT);
  digitalWrite(BUZZER_PIN, LOW);
  input_password.reserve(32);

  Serial.begin(9600);

  uint8_t mac[6] = {0x00,0x02,0x02,0x03,0x04,0x05};

  Ethernet.begin(mac,IPAddress(192,168,200,177));

  int success = udp.begin(5555);

  Serial.print(F("initialize: "));
  Serial.println(success ? "success" : "failed");
  Serial.println(UIPEthernet.localIP());
  
  sendMessage("Sistema ligado");
  sendMessage("Aguardando envio de mensagem");
  sendMessage(UIPEthernet.localIP());

  keypad.setDebounceTime(270); 
}

void loop() {
  checkMessage();
  char key = keypad.getKey();

  if(start_timer){
    if(millis() - previousMillis > RESET_DELAY){
      resetBeep();
      input_password = "";
      start_timer = 0;
    }
  }
  
  if (key){
    Serial.println(key);
    start_timer = 1;
    previousMillis = millis();
    if(key == '*') {
      resetBeep();
      input_password = "";
      start_timer = 0; // reset the input password
    }else if(key == '#') {
      uint input_pass = input_password.toInt();
      switch(input_pass){
        case password_1:
          Serial.println("Pass 1");
          sendMessage("secret");
          passOk();
          break;
        case password_2:
          Serial.println("Pass 2");
          sendMessage("secret");
          passOk();
          break;
        case password_3:
          Serial.println("Pass 3");
          sendMessage("secret");
          passOk();
          break;
        case password_4:
          Serial.println("Pass 4");
          sendMessage("secret");
          passOk();
          break;
        case password_5:
          Serial.println("Pass 5");
          sendMessage("secret");
          passOk();
          break;
        default:
          Serial.println("Senha incorreta");
          resetBeep();
      }
      input_password = "";
      start_timer = 0;
    }else {
      input_password += key; // append new character to input password string
      buttonPress();
    }
  }
}

void sendMessage(char msg[]){
  int success;
    do{
      success = udp.beginPacket(IPAddress(192,168,200,254),5000);
    }while (!success);

    success = udp.print(msg);
    success = udp.endPacket();
    udp.stop();
    Serial.println(udp.begin(5000) ? "success" : "failed");
}

void checkMessage(){
  //check for new udp-packet:
  int size = udp.parsePacket();
  if (size > 0) {
    do{
      char* msg = (char*)malloc(size+1);
      int len = udp.read(msg,size+1);
      msg[len]=0;
      Serial.println(msg);
      
      if (strcmp(msg, "alarme") == 0){
        alarme = 1;
      }else if (strcmp(msg, "prealarme") == 0){
        prealarme = 1;
      }else if(strcmp(msg, "desabilitaalarme") == 0){
        alarme = 0;
        prealarme = 0;
      }
      free(msg);
    }while ((size = udp.available())>0);
    //finish reading this packet:
    udp.flush();
    //Serial.println(F("'"));
  }
}

void passOk(){
  int NOTE_SUSTAIN = 100;
  for(uint8_t nLoop = 0;nLoop < 2;nLoop ++){
    tone(BUZZER_PIN,NOTE_A5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_B5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_C5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_B5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_C5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_D5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_C5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_D5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_E5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_D5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_E5);
    delay(NOTE_SUSTAIN);
    tone(BUZZER_PIN,NOTE_E5);
    delay(NOTE_SUSTAIN);
  }
  noTone(BUZZER_PIN);
}

void resetBeep(){
  tone(BUZZER_PIN, 500, 200);
  delay(200);
  tone(BUZZER_PIN, 1200, 200);
  delay(200);
  tone(BUZZER_PIN, 300, 200);
  delay(200);
  tone(BUZZER_PIN, 1000, 200);
  delay(200);
  tone(BUZZER_PIN, 400, 200);
  delay(200);
  tone(BUZZER_PIN, 1100, 200);
  delay(200);
}

void buttonPress(){
  tone(BUZZER_PIN,NOTE_B5,200);
  delay(100);
  noTone(BUZZER_PIN);
}

header file not operating properly

Using an Arduino Uno microcontroller with Arduino IDE 2.3.2.

Using a 4x4 keypad. Did trouble shooting of hardware and the 4x4 behavior of the keypad is going to the appropriate input pins.

Top level source code calling the correct input pins.
As an example, the keypad is setup with the following layout of the pad:

1 2 3 A
4 5 6 B
7 8 9 C

  • 0 # D

Row 1, if I press 1, get 1, if I press 2 get 1, if I press 3 get 3, if I press A get 1

Each row behaves the same.
Rew 3, press 7 get 7, press 8 get 7, press 9 get 9, press C get 7.

Cannot find the issue in the main source code, thinking there is something in the keypad.h file not agreeing with the IDE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.