Mini Box/House With Automated Door

by arman_a in Circuits > Arduino

46 Views, 1 Favorites, 0 Comments

Mini Box/House With Automated Door

image00019.jpeg
image00020.jpeg

A mini house/box that has a small door that can be opened with an ultrasonic sensor. The door slides to open and close. You can put whatever you want or you can turn the box around to turn it into a dispenser.

This project is made without a breadboard. It can be improved in almost all aspects, but if you want to make something with limited supplies then this might be something for you.


Downloads

Supplies

image00006.jpeg
image00007.jpeg
image00008.jpeg
image00009.jpeg
image00010.jpeg
image00012.jpeg

Circuit components:

  1. Arduino Uno and cable
  2. 7 male to male jumper wires
  3. Ultrasonic sensor
  4. Micro Servo 9g SG90

Box components:

  1. Hardboard (122x61 cm 3,2 mm)
  2. Foamboard

Tools:

  1. Adhesive for wood
  2. Duct tape
  3. utility knife
  4. laptop/pc

Connect the Components

circuit_image.png

Connect the Arduino components like this:

Code

Connect the Arduino to a laptop or computer and use the software Arduino IDE to setup the program. Use this code and test it by uploading the code to the Arduino.


#include <Servo.h>


// Pin ultrasonic sensor

const int trigPin = 10;

const int echoPin = 9;


// Servo object

Servo myServo;


// Variables

long duration;

int distance;


void setup() {

 // Set up pins ultrasonic sensor

 pinMode(trigPin, OUTPUT);

 pinMode(echoPin, INPUT);


 // pin 7

 myServo.attach(7);


 // debugging

 Serial.begin(9600);

}


void loop() {

 // Send out pulse to the ultrasonic sensor

 digitalWrite(trigPin, LOW);

 delayMicroseconds(2);

 digitalWrite(trigPin, HIGH);

 delayMicroseconds(10);

 digitalWrite(trigPin, LOW);


 // Read the echo time

 duration = pulseIn(echoPin, HIGH);


 // Calculate distance in cm

 distance = duration * 0.034 / 2;


 // Print distance to serial monitor for debugging

 Serial.print("Distance: ");

 Serial.print(distance);

 Serial.println(" cm");


 // Map the distance to a servo angle (0 to 90 degrees)


 int angle;

 if (distance > 0 && distance <= 100) {

  angle = map(distance, 0, 100, 90, 0); // 0 cm = 90°, 100 cm = 0°

 } else {

  angle = 0; // Set servo to 0 degrees if out of range

 }


 // Move the servo motor to the calculated angle

 myServo.write(angle);


 // Add a short delay to smooth out the servo movement

 delay(100);

}


Make the Box

image00013.jpeg
image00014.jpeg
image00016.jpeg
image00017.jpeg
image00018.jpeg
  1. Use the hardboard and cut it up with the utility knife. Cut the holes on these sides so the parts and door can be exposed. A laser cutter can make the process quicker.
  2. Put the foamboard on the micro servo.
  3. Put all the components inside the box and make them fit the holes.
  4. Use glue and/or duct tape to make the box and the components stay in their place.


Iterations and Conclusion

image00001.jpeg
image00002.jpeg
image00003.jpeg
image00004.jpeg
image00005.jpeg

Iterations:

I used a carton box to prototype it. I first had to change the code to test the door rotation. I made the door bigger and also used different components to allow the door to have a smooth movement and also cover the door. I also soldered the ultrasonic sensor to the jumper wires.

After making this project, I learned that I need to order materials earlier and I shouldn't expect things to keep working. Laser cutting is something that would make the build time way quicker and using screws will make the box sturdier. 3d printing is also a good alternative. The hardboard was difficult to cut and also easy to break after I folded it. I will know the next time to do it differently. It was still a fun challenge to limit myself and keep making the project smaller. Other ideas like using led's wouldn't be really possible for me without the use of a breadboard.

Downloads