#include <Keypad.h>
const byte r = 4;
const byte c = 4;
int led[] = {13,12,11,10};
int jlh = 4;
byte rp[r] = {9, 8, 7, 6};
byte rc[c] = {5, 4, 3, 2};
byte cc=0;
char keys[r][c] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'.', '0', '=', 'D'}
};
Keypad keypad = Keypad(makeKeymap(keys), rp, rc, r, c);

void setup() {
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  for (int a = 0; a < jlh; a++) {
    pinMode(led[a], OUTPUT);
  }
}

void loop() {
  char key = keypad.getKey();
  if (key == '1') {
    digitalWrite(10, HIGH);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
  }
  else if (key =='2') {
    digitalWrite(10, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
  }
  else if (key == '3') {
    digitalWrite(10, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(12, HIGH);
    digitalWrite(13, LOW);
  }
  else if (key == '4') {
    digitalWrite(10, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(12, HIGH);
    digitalWrite(13, HIGH);
  }
  else if (key == '0') {
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
  }
  else if (key == 'B') {
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    for (int a = 0; a < jlh; a++) {
    digitalWrite(led[a], HIGH);
    delay(100);
    }
  }
  else if (key == 'A') {
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    for (int a = jlh; a >= 0; a--) {
      digitalWrite(led[a], HIGH);
      delay(100);
    }
  }
  else if (key == '5') {
    digitalWrite(10, HIGH);
    delay(100);
    digitalWrite(10, LOW);
    digitalWrite(11, HIGH);
    delay(100);
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
    delay(100);
    digitalWrite(12, LOW);
    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    digitalWrite(12, HIGH);
    delay(100);
    digitalWrite(12, LOW);
    digitalWrite(11, HIGH);
    delay(100);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
  }
}