Smart Cupboard

Published Aug 02, 2024
 0 hours to build
 Beginner

In this project the components used are ultrasonic sensor, servo motor and Arduino. In this the door of the cupboard opens and closes depending on the distance of object/human from the ultrasonic sensor.

display image

Components Used

Connecting Wire Jumper Wires
Connecting Wire Breadboard wires
1
Ultrasonic Module HC-SR04
Ultrasonic module HC-SR04 is generally used for finding distance value and obstacle detection. It can operate in the range 2cm-400cm.
1
SG90 micro servo Motor
DFRobot Accessories 9g micro servo (1.6kg)
1
Arduino Uno R3
https://www.dfrobot.com/product-610.html?tracking=wilKriekbs7BI3GBJZ9IVhugyxsApTR05uQK9f1Br0N3xrQ5uLs2gnzzEIaGP7Qm
1
Description

Step1: Cardboard Cutout Demo

Create a cardboard demo cupboard. Here we have taken cardboard and created a box with a cover as "door".

We are going to control the opening & closing of the door using an ultrasonic Sensor. The door will open automatically when we bring our hands close to the sensor.

 

Step 2: Circuit Connection

 

 the components used are an ultrasonic sensor, servo motor, and arduino. 

Step3 Assembly

So this project is a smart cupboard in which the servo motor is attached with an ultrasonic sense on the top of the cupboard such that when an object such as a human comes close to the ultrasonic sensor, it generates signals and sends them to the servo motor to rotate by angle of 90° such that the door of the cupboard gets open.

 

when an object such as a human moves behind that is it gets out of the range of the ultrasonic sensor then the signals are now stopped being generated and the motor again rotates by 90°so that the door closes. so the initial position of the servo motor was 90°, on coming close it became zero degrees then on moving far, it became 90°. this is a sample model just for demonstration purposes and the supply to our Arduino is provided through the lead. the other means of supply can also be used.

Step4: Code

#include <Servo.h>
Servo my1;
int trigPin=11;
int echoPin= 9;
long duration, cm, inches;
void setup()
{
  my1.attach(8);
  Serial.begin(9600);
  pinMode(trigPin,OUTPUT);
  pinMode(echoPin,INPUT);
}
void loop()
{
  digitalWrite(trigPin,LOW);
  delayMicroseconds(1);
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(1);
  digitalWrite(trigPin,LOW);
  pinMode(echoPin,INPUT);
  duration=pulseIn(echoPin,HIGH);
  cm=(duration/2)/29.1;
  inches=(duration/2)/74;
  Serial.print(inches);
  Serial.print("in");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
  delay(1000);
  my1.write(0);
  if (cm<20){
    my1.write(90);
  }
  if (cm>20){
    my1.write(0);
  }
}  

Video

Codes

Downloads

1000076787 Download
smart_cupboard Download
Comments
Ad