Project in progress
Keypad Garage Opener

Keypad Garage Opener

Replaced a bad keypad on the outside of my garage door.

  • 499 views
  • 0 comments
  • 1 respect

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
3drag
3D Printer (generic)

Apps and online services

About this project

Keypad to open garage door. Password can be changed through the keypad and is saved to EEPROM. Changing the password requires knowing the saved password. See code for instructions on setting password. Green LED to show correct password, red LED to show incorrect password. Uses a servo to press the button on a vehicle fob. Ability to reset password to 1234 with tactile button in case password forgot or new resident.

I am sharing this because so many others have shared projects and helped me piece this together. I am not the best code writer, so if there is something I could do better, I am all ears!

Also note I am using the low voltage wire which was existing in my walls which originally went to the door blocked sensors. My Wayne Dalton opener does not utilize these sensors so I was able to plug a 5V power supply in the ceiling and connect the power to the low voltage cable to the Arduino. I don't recommend disabling the safety sensors if your door has them.

Video was before I soldered the wires to the final NANO.

Initial testing

Completed Project

Code

Garage Door KeypadArduino
See instructions in code
//  Garage Door Opener using servo to press remote button
//
//  Correct entry of 4 digit code will illuminate the Green LED
//  Incorrect entry of 4 digit code will illuminate the Red LED
//
//  To change the code:
//  Press the "#" button on keypad and the Blue LED will illimunate
//  While Blue LED is illuminated, enter the initial password
//    Correct entry will illuminate the Blue and Yellow LEDs
//    Incorrect entry will illuminate the Red LED (must start over and press "#" on keypad)
//  While the Blue and Yellow LEDs are illuminated, enter the new password.
//    Successful change of password will illuminate the Green LED.
//
//  To reset the password to 1234, press the reset button

#include<Keypad.h>
#include<EEPROM.h>
#include<Servo.h>

  Servo ServoMotor;

  char password[4];
  char initial_password[4],new_password[4];
  int i=0;
  int LED_G = 14;
  int LED_R = 15;
  int LED_B = 16;
  int LED_Y = 17;
  char key_pressed=0;

  const int Reset = 12;
  int value1 = HIGH;

  const byte rows = 4; 
  const byte columns = 3; 
  char keys[rows][columns] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
  };

  byte row_pins[rows] = { 7, 2, 3, 5};
  byte column_pins[columns] = { 6, 8, 4};   
  Keypad keypad_key = Keypad( makeKeymap(keys), row_pins, column_pins, rows, columns);

  //#define LED_R 10 // define red LED
  //#define LED_G 11 // define green LED

void setup()
  {
  Serial.begin (9600);
  pinMode(Reset, INPUT);
  pinMode(LED_R, OUTPUT);
  pinMode(LED_G, OUTPUT);
  pinMode(LED_B, OUTPUT);
  pinMode(LED_Y, OUTPUT);
  delay(1000);
  ServoMotor.attach(13);

  // check if the password has been changed
  if (EEPROM.read(256) != 123) { // not equal to 123
    EEPROM.write(256, 123); // write value of 123 to byte 256
    initialpassword(); // set first password to 1234
  }
    else { // if byte 256 is equal to 123
      EEPROM.get (0, password); // get last password before power failure
    }
  }

void loop()
{
  digitalWrite(LED_R, LOW);
  digitalWrite(LED_G, LOW);
  key_pressed = keypad_key.getKey();

  value1 = digitalRead (Reset);
  if (value1 == HIGH)
    initialpassword();
  
  if(key_pressed=='#')
    change();

  if (key_pressed)
  {

    password[i++]=key_pressed;
    Serial.println(key_pressed);
      }

  if(i==4)
  {
    delay(200);
    for(int j=0;j<4;j++)
      initial_password[j]=EEPROM.read(j);
    if(!(strncmp(password, initial_password,4)))
    {

      Serial.println("Password Accepted");
      digitalWrite(LED_G, HIGH);
      ServoMotor.write(78);
      delay(delay);
      ServoMotor.write(90);
      Serial.println("Press # to change");
      delay(delay);
      Serial.println("Enter Password:");
      i=0;

    }

    else
    {
      digitalWrite(LED_R, HIGH);
      Serial.println("Wrong Password");;
      Serial.println("Press # to change");
      delay(delay);
      Serial.println("Enter Password");

      i=0;
    }
  }
}

void change()

{
  int j=0;
  Serial.println("Current Password");
  digitalWrite(LED_B, HIGH);
  while(j<4)
  {
    char key=keypad_key.getKey();
    if(key)
    {
      new_password[j++]=key;
      Serial.println(key);
    }
    key=0;
  }
  delay(delay);
  if((strncmp(new_password, initial_password, 4)))
  {
    Serial.println("Wrong Password");
    Serial.println("Try Again");
    delay(200);
    digitalWrite(LED_B, LOW);
    digitalWrite(LED_R, HIGH);
    delay(delay);
    digitalWrite(LED_R, LOW);
  }
  else
  {
    j=0;
    Serial.println("New Password:");
    digitalWrite(LED_Y, HIGH);
    while(j<4)
    {
      char key=keypad_key.getKey();
      if(key)
      {
        initial_password[j]=key;
        Serial.println(key);
        EEPROM.write(j,key);
        j++;
      }
    }
    Serial.println("Password Changed");
    delay(200);
    digitalWrite(LED_B, LOW);
    digitalWrite(LED_Y, LOW);
    digitalWrite(LED_G, HIGH);
    delay(delay);
    digitalWrite(LED_G, LOW);
  }
  Serial.println("Enter Password");
  key_pressed=0;
}

void initialpassword(){
  for(int j=0;j<4;j++)
    EEPROM.write(j, j+49);
  for(int j=0;j<4;j++)
    initial_password[j]=EEPROM.read(j);
} 

Custom parts and enclosures

Servo_fob_arduino_mount
This positions the servo to press the button on the fob. Wayne Dalton fob. Custom needed for other brands
Keypad case
Allows the keypad to be mounted to wall and adds the LEDs. Uses Adafruit Keypad 3845.

Schematics

Schematic
Schematic 9nu1iq7ih7

Comments

Similar projects you might like

IoT arduino ESP Garage Door opener (UD)

Project in progress by David Smerkous

  • 17,315 views
  • 8 comments
  • 22 respects

Keypad Entry Lock

Project in progress by 3 developers

  • 13,929 views
  • 12 comments
  • 35 respects

Touchless Hand Gesture Door Opener

Project tutorial by 3 developers

  • 2,774 views
  • 0 comments
  • 11 respects

Windows 10 Universal Bluetooth Garage Door Opener

Project showcase by Ronald P. Kessler

  • 2,459 views
  • 1 comment
  • 6 respects

Universal Touch-Free Keypad Adaptor for Existing Keypads

Project tutorial by Francesco Gritti

  • 1,056 views
  • 0 comments
  • 5 respects
Add projectSign up / Login