How can I insert more than one (3 in case) keypad in ArduinoMega

Hello everyone.
I´m new on Arduino.
I’m doing a project for my house. My project is to build a number lock for each of the 3 gates to enter my house. For that I’m using a Serial Rele Module from ; 3 keypad module 4x3; one Arduino mega.
I already did the programming for only one door.
Now I need some help to insert and program the others 2 keypads using the 2nd ad the 3rd reles of the module.
The code that I did was this:

#include “Password.h”
#include “Keypad.h”

Password password = Password( “250271” );

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

char keys[ROWS][COLS] = {

byte rowPins[ROWS] = {2,3,4,5};
byte colPins[COLS] = {6,7,8,9};

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

#include <SerialRelay.h>

const byte NumModules = 1;
SerialRelay relays(4,5,NumModules); // (data, clock, number of modules)

void setup(){
digitalWrite(13, LOW);

void loop(){

void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
Serial.print("Digitado: ");
switch (eKey){
case ‘#’: guessPassword(); break;

void guessPassword(){
Serial.print("Verificando, aguarde… ");
if (password.evaluate()){
Serial.println("Abrindo a porta "); //
relays.SetRelay(1, SERIAL_RELAY_ON, 1); // turn the relay ON
delay(2000); // wait for a second
relays.SetRelay(1, SERIAL_RELAY_OFF, 1); // turn the relay OFF
delay(100); // wait for a second
password.reset(); //apaga a senha
digitalWrite(13, LOW);
Serial.println(“PASSWORD INVALIDA”);
password.reset(); //apaga a senha

Sorry for any English mistakes (not a born speaker)
The code is not tested yet, I’m waiting for the material to arrive.
Thaks a lot for any help.

Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom. :slight_smile: