ARDUINO PROJECTS

Arduino Based Smart Garage Door

hi

Arduino Based Smart Garage Door Circuit Diagram

Arduino Based Smart Garage Door Circuit

Arduino Program for Smart Garage Door

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

// ================= LCD =================
LiquidCrystal_I2C lcd(0x27, 16, 2);

// ================= SERVO =================
Servo doorServo;
const int SERVO_PIN = 9;
const int SERVO_CLOSED = 5;
const int SERVO_OPEN = 135;   // ~90% capacity

// ================= IR SENSOR =================
const int IR_PIN = 2;

// ================= SYSTEM =================
int loadProgress = 0;           // 0–100
bool authenticated = false;

// ================= TIMING =================
unsigned long lastUpdate = 0;
const int LOAD_STEP = 5;        // % increase per step
const int LOAD_INTERVAL = 200;  // ms per step
const int OPEN_DELAY = 5000;    // 5 seconds

// ================= SETUP =================
void setup() {
  pinMode(IR_PIN, INPUT);

  doorServo.attach(SERVO_PIN);
  doorServo.write(SERVO_CLOSED);

  lcd.init();
  lcd.backlight();

  showIdleScreen();
}

// ================= LOOP =================
void loop() {
  if (!authenticated) {
    handleAuthentication();
  }
}

// ================= FUNCTIONS =================

void showIdleScreen() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Garage Locked");
  lcd.setCursor(0, 1);
  lcd.print("Hold Hand...");
}

void handleAuthentication() {
  bool handDetected = (digitalRead(IR_PIN) == LOW);

  if (handDetected) {
    if (millis() - lastUpdate > LOAD_INTERVAL) {
      lastUpdate = millis();
      loadProgress += LOAD_STEP;

      if (loadProgress > 100) loadProgress = 100;

      drawLoadingBar(loadProgress);

      if (loadProgress >= 50) {
        authenticated = true;
        accessGranted();
      }
    }
  } else {
    // Reset if hand removed
    if (loadProgress > 0) {
      loadProgress = 0;
      showIdleScreen();
    }
  }
}

void drawLoadingBar(int percent) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Authenticating");

  lcd.setCursor(0, 1);
  lcd.print("[");

  int bars = map(percent, 0, 100, 0, 10);
  for (int i = 0; i < 10; i++) {
    if (i < bars) lcd.print("#");
    else lcd.print(" ");
  }

  lcd.print("]");
}

void accessGranted() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Access Granted");
  lcd.setCursor(0, 1);
  lcd.print("Opening Door");

  openDoorSlow();
  delay(OPEN_DELAY);
  closeDoorSlow();

  // Reset system
  loadProgress = 0;
  authenticated = false;
  showIdleScreen();
}

void openDoorSlow() {
  for (int pos = SERVO_CLOSED; pos <= SERVO_OPEN; pos++) {
    doorServo.write(pos);
    delay(15);   // smooth & gentle
  }
}

void closeDoorSlow() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Closing Door");

  for (int pos = SERVO_OPEN; pos >= SERVO_CLOSED; pos--) {
    doorServo.write(pos);
    delay(15);
  }
}

3D Printing Parts

3d printed slider mechanism

gfg

3d printed slider mechanism design

ght

If you want to make this device more smaller you can use PCB and i would suggest JLCPCB

gf

They have fast shipping with more affordable options, and now they have JLCONE which makes everything pretty much easier.

JLCONE is a application that is available for both desktop and mobile and you can manage your orders and other services in a single platform.

Jeevan

ADMIN

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button