#include <Keypad.h>

const byte ROWS = 4; // Number of rows on the keypad
const byte COLS = 4; // Number of columns on the keypad

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

byte rowPins[ROWS] = {16, 4, 0, 2}; // Connect to the row pinouts of the keypad
byte colPins[COLS] = {19, 18, 5, 17}; // Connect to the column pinouts of the keypad

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

const int ledPin = 23; // Pin connected to the LED

void setup() {
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
}

void loop() {
  char key = keypad.getKey();
  
  if (key == 'A') { // If 'ON' key is pressed
    digitalWrite(ledPin, HIGH); // Turn LED on
  } else if (key == 'B') { // If 'OFF' key is pressed
    digitalWrite(ledPin, LOW); // Turn LED off
  }
}