# interfacing keypad

**URL:** <https://forum.arduino.cc/t/interfacing-keypad/389651>\
**Category:** Programming\
**Created:** [June 2, 2016, 10:15am UTC](https://forum.arduino.cc/t/interfacing-keypad/389651 "2016-06-02T10:15:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sachin13](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@sachin13](https://forum.arduino.cc/u/sachin13)\
**Post date:** [June 2, 2016, 10:15am UTC](https://forum.arduino.cc/t/interfacing-keypad/389651/1 "2016-06-02T10:15:11Z")

</div>

How to interface keypad with esp8266.  
I am writing below code in arduino ide  
and it is providing garbage value in serial monitor.  
Has anyone worked on esp8266 keypad interface with arduino ide?Please help.

#include \<Keypad.h\>

const byte ROWS = 4; //four rows  
const byte COLS = 4; //four columns  
//define the cymbols on the buttons of the keypads  
char hexaKeys[ROWS][COLS] = {  
{'0','1','2','3'},  
{'4','5','6','7'},  
{'8','9','a','b'},  
{'c','d','e','f'}  
};  
byte rowPins[ROWS] = {16, 5, 4, 14}; //connect to the row pinouts of the keypad  
byte colPins[COLS] = {12, 13, 3, 1}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad  
Keypad cusomKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

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

void loop(){  
char customKey = cusomKeypad.getKey();

if (customKey != NO\_KEY){  
Serial.println(customKey);  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 2, 2016, 10:16am UTC](https://forum.arduino.cc/t/interfacing-keypad/389651/2 "2016-06-02T10:16:29Z")

</div>

```cpp
byte colPins[COLS] = {12, 13, 3, 1}; //connect to the column pinouts of the keypad

```

Having one of the column pins on the hardware serial port pin WILL cause problems with sending and receiving serial data.

---

<div class="post-metadata">

**Author:** ![sachin13](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@sachin13](https://forum.arduino.cc/u/sachin13)\
**Post date:** [June 2, 2016, 2:37pm UTC](https://forum.arduino.cc/t/interfacing-keypad/389651/3 "2016-06-02T14:37:12Z")

</div>

means having 1 as a hardware pin u want to say

---

<div class="post-metadata">

**Author:** ![groundFungus](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@groundFungus](https://forum.arduino.cc/u/groundFungus)\
**Post date:** [June 2, 2016, 3:16pm UTC](https://forum.arduino.cc/t/interfacing-keypad/389651/4 "2016-06-02T15:16:19Z")

</div>

May I suggest an alternative keypad interface. [I2C keypad for 8266](https://www.hackster.io/venkatesh_rao/i2c-keypad-73a012).

i2ckeypad library  
[I2C Port Expander And Keypads](http://playground.arduino.cc/Main/I2CPortExpanderAndKeypads)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 2, 2016, 3:33pm UTC](https://forum.arduino.cc/t/interfacing-keypad/389651/5 "2016-06-02T15:33:14Z")

</div>

> means having 1 as a hardware pin u want to say

You can't change the fact that pin 1 is a hardware serial pin. You can change the fact that you have the keypad connected to that pin.

Change what you can; accept what you can't change.

---

<div class="post-metadata">

**Author:** ![groundFungus](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@groundFungus](https://forum.arduino.cc/u/groundFungus)\
**Post date:** [June 2, 2016, 4:20pm UTC](https://forum.arduino.cc/t/interfacing-keypad/389651/6 "2016-06-02T16:20:25Z")

</div>

Also, on the ESP8266, pin 3 is RX0 (hardware RX).

> 1. TX0
> 2. TX1
> 3. RX0

From [esp8266\_gpio\_pin\_allocations](http://www.esp8266.com/wiki/doku.php?id=esp8266_gpio_pin_allocations)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 9:55pm UTC](https://forum.arduino.cc/t/interfacing-keypad/389651/7 "2021-05-05T21:55:33Z")

</div>

Closed on May 5, 2021, 9:55pm UTC


