user72879: I'm working on a research project that allows me to press a button on a matrix that then outputs a parameter like temperature, humidity etc. But I cannot find out what is wrong with the buttons, when I press them nothing is happening. Thank you very much! I've attached what the connection between the Arduino and the keypad looks like.
#include <EEPROM.h>
#include <GravityTDS.h>
#include "DHT.h"
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Servo.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define DHTPIN 7
#define DHTTYPE DHT11   // DHT 11 
#define SensorPin A0            //pH meter Analog output to Arduino Analog Input 0
#define Offset 0.00            //deviation compensate
#define LED 13
#define samplingInterval 20
#define printInterval 800
#define ArrayLenth  40    //times of collection
#define PUMPPIN 9
#define ONE_WIRE_BUS 4
int pHArray[ArrayLenth];   //Store the average value of the sensor feedback
int pHArrayIndex = 0;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
Servo myservo;
GravityTDS gravityTds;
DHT dht(DHTPIN, DHTTYPE);

char incomingByte;
String inputString;
int pump = 9; // Output for pump Control
double avg;
int h;
float t;
float tdsValue;
float temperature = t;
static unsigned long samplingTime = millis();
static unsigned long printTime = millis();
static float pHValue, voltage;

const byte ROWS = 4;
const byte COLS = 4;

char hexaKeys[ROWS][COLS] = {
  {'A', 'B', 'C', 'D'},
  {'E', 'F', 'G', 'H'},
  {'I', 'J', 'K', 'L'},
  {'M', 'N', 'O', 'P'}
};

byte rowPins[ROWS] = {44, 42, 40, 38};
byte colPins[COLS] = {36, 34, 32, 30};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup() {

  lcd.begin();
  pinMode(pump, OUTPUT); //sets the digital pin as output
  digitalWrite(pump, LOW); // Initial state of the pump
  Serial.begin(9600);
  gravityTds.setPin(A1);
  gravityTds.setAref(5.0);
  gravityTds.setAdcRange(1024);
  gravityTds.begin();
  dht.begin();
  sensors.begin();
}

double averagearray(int* arr, int number) {
  int i;
  int max, min;
  long amount = 0;
  if (number <= 0) {
    Serial.println("Error number for the array to avraging!/n");
    return 0;
  }
  else if (number < 5) { //less than 5, calculated directly statistics
    for (i = 0; i < number; i++) {
      amount += arr[i];
    }
    avg = amount / number;
    return avg;
  } else {
    if (arr[0] < arr[1]) {
      min = arr[0]; max = arr[1];
    }
    else {
      min = arr[1]; max = arr[0];
    }
    for (i = 2; i < number; i++) {
      if (arr[i] < min) {
        amount += min;      //arr<min
        min = arr[i];
      } else {
        if (arr[i] > max) {
          amount += max;  //arr>max
          max = arr[i];
        } else {
          amount += arr[i]; //min<=arr<=max
        }
      }//if
    }//for
    avg = (double)amount / (number - 2);
  }//if
  return avg;
}

void loop() {
  lcd.print("working so far. test1");
  delay(5000);
  char customKey = customKeypad.getKey();
  int pumptime = 1000;
  switch (customKey) {
    case 'A':
      // pump
      digitalWrite(pump, HIGH); // on pump
      delay(pumptime);
      digitalWrite(pump, LOW);//off pump
      break;
    case 'B':
      // add pump time
      pumptime += 500;
      break;
    case 'C':
      // less pump time
      pumptime -= 500;
      break;
    case 'D':
      // reset pump time
      pumptime = 1000;
      break;
    case 'E':
      //temp
      sensors.requestTemperatures();
      lcd.setCursor(0, 0);
      lcd.print("Celsius temperature: ");
      lcd.print(sensors.getTempCByIndex(0));
      lcd.print((char)223);
      lcd.print("C");
      delay(5000);
      lcd.clear();
      break;
    case 'F':
      // Temperature & humidity
      h = dht.readHumidity();
      t = dht.readTemperature();
      lcd.setCursor(0, 0);
      lcd.print("Humidity:");
      lcd.print(h);
      lcd.print("%");
      lcd.setCursor(0, 1);
      lcd.print("Temperature:");
      lcd.print(t);
      lcd.print((char)223);
      lcd.print("C");
      delay(5000);
      lcd.clear();
      break;
    case 'G':
      // TDS
      h = dht.readHumidity();
      t = dht.readTemperature();
      temperature = t;
      gravityTds.setTemperature(temperature);
      gravityTds.update();
      tdsValue = gravityTds.getTdsValue();
      lcd.setCursor(0, 0);
      lcd.print("TDS: ");
      lcd.print(tdsValue);
      lcd.print("ppm");
      delay(5000);
      lcd.clear();
      delay(5000);
      lcd.clear();
      break;
    case 'H':
      // pH
      lcd.clear();
      lcd.setCursor(0, 0);
      if (millis() - samplingTime > samplingInterval)
      {
        pHArray[pHArrayIndex++] = analogRead(SensorPin);
        if (pHArrayIndex == ArrayLenth)pHArrayIndex = 0;
        voltage = averagearray(pHArray, ArrayLenth) * 5.0 / 1024;
        pHValue = 3.5 * voltage + Offset;
        samplingTime = millis();
      }
      if (millis() - printTime > printInterval)  //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
      {
        lcd.print("Voltage:");
        lcd.print(voltage, 2);
        lcd.print("    pH value: ");
        lcd.println(pHValue, 2);
        digitalWrite(LED, digitalRead(LED) ^ 1);
        printTime = millis();
      }
      delay(5000);
      lcd.clear();
      break;
    case 'I':
      // test buttons
      lcd.print("buttons are working");
      delay(5000);
      lcd.clear();
      break;
    case 'J':
      //
      lcd.print("buttons are working");
      delay(5000);
      lcd.clear();
      break;
    case 'K':
      //
      lcd.print("buttons are working");
      delay(5000);
      lcd.clear();
      break;
    case 'L':
      //
      lcd.print("buttons are working");
      delay(5000);
      lcd.clear();
      break;
    case 'M':
      //
      lcd.print("buttons are working");
      delay(5000);
      lcd.clear();
      break;
    case 'N':
      //
      lcd.print("buttons are working");
      delay(5000);
      lcd.clear();
      break;
    case 'O':
      //
      lcd.print("buttons are working");
      delay(5000);
      lcd.clear();
      break;
    case 'P':
      //
      lcd.print("buttons are working");
      delay(5000);
      lcd.clear();
      break;
  }//switch
  lcd.print("working so far. test2");
  myservo.write(0);
  delay(10000);
  myservo.write(90);

  delay(1800000);

}


user60210: Imho, your delay function in loop() is a root cause.
First, you should remove the below code
  myservo.write(0);
  delay(10000);
  myservo.write(90);

  delay(1800000);

Then,please reduce delay(5000) -> delay(200).
Build and execute your code.
Press and hold a single button and take a look what happen in LCD. At least, you able to confirm the keypad hardware works well or not.

72879: <p>I'm working on a research project that allows me to press a button on a matrix that then outputs a parameter like temperature, humidity etc. But I cannot find out what is wrong with the buttons, when I press them nothing is happening. Thank you very much! I've attached what the connection between the Arduino and the keypad looks like.</p>
<pre><code>#include &lt;EEPROM.h&gt;
#include &lt;GravityTDS.h&gt;
#include &quot;DHT.h&quot;
#include &lt;LiquidCrystal_I2C.h&gt;
#include &lt;Wire.h&gt;
#include &lt;Servo.h&gt;
#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt;
#include &lt;Keypad.h&gt;
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define DHTPIN 7
#define DHTTYPE DHT11   // DHT 11 
#define SensorPin A0            //pH meter Analog output to Arduino Analog Input 0
#define Offset 0.00            //deviation compensate
#define LED 13
#define samplingInterval 20
#define printInterval 800
#define ArrayLenth  40    //times of collection
#define PUMPPIN 9
#define ONE_WIRE_BUS 4
int pHArray[ArrayLenth];   //Store the average value of the sensor feedback
int pHArrayIndex = 0;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&amp;oneWire);
Servo myservo;
GravityTDS gravityTds;
DHT dht(DHTPIN, DHTTYPE);

char incomingByte;
String inputString;
int pump = 9; // Output for pump Control
double avg;
int h;
float t;
float tdsValue;
float temperature = t;
static unsigned long samplingTime = millis();
static unsigned long printTime = millis();
static float pHValue, voltage;

const byte ROWS = 4;
const byte COLS = 4;

char hexaKeys[ROWS][COLS] = {
  {'A', 'B', 'C', 'D'},
  {'E', 'F', 'G', 'H'},
  {'I', 'J', 'K', 'L'},
  {'M', 'N', 'O', 'P'}
};

byte rowPins[ROWS] = {44, 42, 40, 38};
byte colPins[COLS] = {36, 34, 32, 30};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup() {

  lcd.begin();
  pinMode(pump, OUTPUT); //sets the digital pin as output
  digitalWrite(pump, LOW); // Initial state of the pump
  Serial.begin(9600);
  gravityTds.setPin(A1);
  gravityTds.setAref(5.0);
  gravityTds.setAdcRange(1024);
  gravityTds.begin();
  dht.begin();
  sensors.begin();
}

double averagearray(int* arr, int number) {
  int i;
  int max, min;
  long amount = 0;
  if (number &lt;= 0) {
    Serial.println(&quot;Error number for the array to avraging!/n&quot;);
    return 0;
  }
  else if (number &lt; 5) { //less than 5, calculated directly statistics
    for (i = 0; i &lt; number; i++) {
      amount += arr[i];
    }
    avg = amount / number;
    return avg;
  } else {
    if (arr[0] &lt; arr[1]) {
      min = arr[0]; max = arr[1];
    }
    else {
      min = arr[1]; max = arr[0];
    }
    for (i = 2; i &lt; number; i++) {
      if (arr[i] &lt; min) {
        amount += min;      //arr&lt;min
        min = arr[i];
      } else {
        if (arr[i] &gt; max) {
          amount += max;  //arr&gt;max
          max = arr[i];
        } else {
          amount += arr[i]; //min&lt;=arr&lt;=max
        }
      }//if
    }//for
    avg = (double)amount / (number - 2);
  }//if
  return avg;
}

void loop() {
  lcd.print(&quot;working so far. test1&quot;);
  delay(5000);
  char customKey = customKeypad.getKey();
  int pumptime = 1000;
  switch (customKey) {
    case 'A':
      // pump
      digitalWrite(pump, HIGH); // on pump
      delay(pumptime);
      digitalWrite(pump, LOW);//off pump
      break;
    case 'B':
      // add pump time
      pumptime += 500;
      break;
    case 'C':
      // less pump time
      pumptime -= 500;
      break;
    case 'D':
      // reset pump time
      pumptime = 1000;
      break;
    case 'E':
      //temp
      sensors.requestTemperatures();
      lcd.setCursor(0, 0);
      lcd.print(&quot;Celsius temperature: &quot;);
      lcd.print(sensors.getTempCByIndex(0));
      lcd.print((char)223);
      lcd.print(&quot;C&quot;);
      delay(5000);
      lcd.clear();
      break;
    case 'F':
      // Temperature &amp; humidity
      h = dht.readHumidity();
      t = dht.readTemperature();
      lcd.setCursor(0, 0);
      lcd.print(&quot;Humidity:&quot;);
      lcd.print(h);
      lcd.print(&quot;%&quot;);
      lcd.setCursor(0, 1);
      lcd.print(&quot;Temperature:&quot;);
      lcd.print(t);
      lcd.print((char)223);
      lcd.print(&quot;C&quot;);
      delay(5000);
      lcd.clear();
      break;
    case 'G':
      // TDS
      h = dht.readHumidity();
      t = dht.readTemperature();
      temperature = t;
      gravityTds.setTemperature(temperature);
      gravityTds.update();
      tdsValue = gravityTds.getTdsValue();
      lcd.setCursor(0, 0);
      lcd.print(&quot;TDS: &quot;);
      lcd.print(tdsValue);
      lcd.print(&quot;ppm&quot;);
      delay(5000);
      lcd.clear();
      delay(5000);
      lcd.clear();
      break;
    case 'H':
      // pH
      lcd.clear();
      lcd.setCursor(0, 0);
      if (millis() - samplingTime &gt; samplingInterval)
      {
        pHArray[pHArrayIndex++] = analogRead(SensorPin);
        if (pHArrayIndex == ArrayLenth)pHArrayIndex = 0;
        voltage = averagearray(pHArray, ArrayLenth) * 5.0 / 1024;
        pHValue = 3.5 * voltage + Offset;
        samplingTime = millis();
      }
      if (millis() - printTime &gt; printInterval)  //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
      {
        lcd.print(&quot;Voltage:&quot;);
        lcd.print(voltage, 2);
        lcd.print(&quot;    pH value: &quot;);
        lcd.println(pHValue, 2);
        digitalWrite(LED, digitalRead(LED) ^ 1);
        printTime = millis();
      }
      delay(5000);
      lcd.clear();
      break;
    case 'I':
      // test buttons
      lcd.print(&quot;buttons are working&quot;);
      delay(5000);
      lcd.clear();
      break;
    case 'J':
      //
      lcd.print(&quot;buttons are working&quot;);
      delay(5000);
      lcd.clear();
      break;
    case 'K':
      //
      lcd.print(&quot;buttons are working&quot;);
      delay(5000);
      lcd.clear();
      break;
    case 'L':
      //
      lcd.print(&quot;buttons are working&quot;);
      delay(5000);
      lcd.clear();
      break;
    case 'M':
      //
      lcd.print(&quot;buttons are working&quot;);
      delay(5000);
      lcd.clear();
      break;
    case 'N':
      //
      lcd.print(&quot;buttons are working&quot;);
      delay(5000);
      lcd.clear();
      break;
    case 'O':
      //
      lcd.print(&quot;buttons are working&quot;);
      delay(5000);
      lcd.clear();
      break;
    case 'P':
      //
      lcd.print(&quot;buttons are working&quot;);
      delay(5000);
      lcd.clear();
      break;
  }//switch
  lcd.print(&quot;working so far. test2&quot;);
  myservo.write(0);
  delay(10000);
  myservo.write(90);

  delay(1800000);
</code></pre>
<p>}</p>
<p><a href="https://i.stack.imgur.com/HG4eb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HG4eb.jpg" alt="enter image description here" /></a></p>
 60210: <p>Imho, your delay function in loop() is a root cause.
First, you should remove the below code</p>
<pre><code>  myservo.write(0);
  delay(10000);
  myservo.write(90);

  delay(1800000);
</code></pre>
<p>Then,please reduce delay(5000) -&gt; delay(200).
Build and execute your code.
Press and hold a single button and take a look what happen in LCD. At least, you able to confirm the keypad hardware works well or not.</p>
