Ahmad Satria
Published

IoT Based Automatic Garage Door Opening System Prototype

This project is very helpful for garage owners to open or close the garage door automatically without manual

BeginnerWork in progress706
IoT Based Automatic Garage Door Opening System Prototype

Things used in this project

Hardware components

ESP32
Espressif ESP32
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×2
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
Cable jumper : Male - male Male - female Female - female
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Tape, Duct
Tape, Duct
Scissor, Electrician
Scissor, Electrician

Story

Read more

Code

Project_Satria_2.ino

C/C++
#include

<Servo.h>
int trig=8;
int echo=9;
int led=10;
int servo=10;
Servo servo;

//int distance,duration;
void setup() {
  // put your setup code here, to run once:
pinMode(trig,OUTPUT);
pinMode(buzz,OUTPUT);
pinMode(echo,INPUT);
Serial.begin(9600);
servo.attach(11);
}

void loop() {
  // put your main code here, to run repeatedly:
if (calc_dis()<15)
{
  digitalWrite(buzz,HIGH);
}
else
{
  digitalWrite(buzz,LOW);
}

if (calc_dis()<10)
{
  for (int i=0;i<=540;i++)
  {
    servo.write(i);
    delay(1);
  }
  delay(100);
  for (int i=540;i>=0;i--)
  {
    servo.write(i);
    delay(1);
  }
  delay(100);
}
}


int calc_dis()
{
  int duration,distance;
  digitalWrite(trig,HIGH);
  delay(dt);
  digitalWrite(trig,LOW);
  duration=pulseIn(echo,HIGH);
  distance = (duration/2) / 29.1;
  return distance;
}

Credits

Ahmad Satria
1 project • 0 followers

Comments