To simulate 4x4 Keypad and LCD 16x2 with arduino in proteus

COMPONENTS REQUIRED : 



  • ARDUINO


  • LCD 16x2


  • KEYPAD 4x4

   

  • WIRES




CODE:

#include <Keypad.h>
#include <LiquidCrystal.h>

const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 =9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

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] = {
  {'7','8','9','/'},
  {'4','5','6','x'},
  {'1','2','3','-'},
  {'C','0','=','+'}
};
byte rowPins[ROWS] = {3, 2, A4, A5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad

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

void setup(){
  Serial.begin(9600);
    lcd.begin(16, 2);
    lcd.setCursor(0, 0);
}
  
void loop(){
  char customKey = customKeypad.getKey();
  
  if (customKey){
    Serial.println(customKey);
    lcd.print(customKey);
  }
}

LIBRARIES:



PROTEUS FILE:


VIDEO:



Comments