Final Project: Automatically Opening Closet Door

Assignment

complete your final project

Steps needed to complete final project:

  1. Design an expandable circuit around an attiny with space for a servo, a couple indicators, and a sensor/remote
  2. Determine the dimensions of the door and frame
  3. Design an opening mechanism for the door
    • design and print the wall anchor
    • design and cut the actuator
    • design and print the moving component manifold
  4. Etch, solder, and program the board.
  5. Attach and assemble the product

Design of the Circuit

Project Board File Project Sketch File

I designed the circuit around an ATTiny45. The Tiny45 is a very versitile and cheap AVR. The board would have space for expandable networking communcation through I 2C, a servo port, and a 3-pin expansion port (signal and power) for sensors.

I toner transferred the design to the board:

Toner Transfer

I etched the board with hydrochloric acid.

Etched Board

Then, I soldered and tested the board

Soldering and Testing

The files for the circuit and the BOM for the electronics can be found here

Circuit Pererphirals

At first, I planned on making a remote for the door, but time was running thin. So, I decided to use a motion sensor to detect a hand movement over the sensor. The sensor was a PIR motion detector

I designed a mount for the motion sensor circuit, which communicated over simple one-line HIGH LOW digital. The 3D printed mount and cover can be found here.

Mount for Sensor

Design of the Opening Mechanism

The opening mechanism is a door attachment, a wall anchor, and two CNC'd shafts that are held together with a screw that functions as an axis of rotation.

The servo will be housed in a 3D printed servo horn and container. The 3D printed container will be drywall screwed into the wall. This will require two screws so that the rotation of the door doesn't compromise strength.

Files for the 3D printed pieces can be found here.

Programming

The programming for the board is very simple. It waits for something to pass in front of the center. TThen, it moves the servo to a user-defined "open" angle and sets the door state to open. Next, it turns of the servo's power to conserve energy and extend the lifetime of the servo. When something passes in front of the sensor again, the board runs the sequence with a "closed" angle, which completes the cycle.

    //Copyright 2016 Alex Brufsky
//Written by Alex Brufsky 
#include <SoftwareServo.h>


int led = 1;           // the pin that the LED is attached to
int distance = 3;      // the pin that the Motion Sensor is attached to
int servoPin = 4;      // the pin that the Servo is attached to
int openPosition = 1;   // User Defined Open
int closedPosition = 145;   // User Defined Closed
boolean doorIsOpen = LOW;
SoftwareServo doorServo;


void setup() {

  //Begin with the door closed and attached

  pinMode(led, OUTPUT);
  pinMode(distance, INPUT);
  doorServo.attach(servoPin);
  doorServo.write(closedPosition);
  doorIsOpen = LOW;
}

void openDoor() {

  //door open is toggled to yes and then door is opened and servo is detached to save energy

  if(doorServo.attached() != 1) {
    doorServo.attach(servoPin);
    delay(10);
  }

  doorServo.write(openPosition);
  doorIsOpen = HIGH;
}

void closeDoor() {

  //door open is toggled to no and then door is closed and servo is detached to save energy

 if(doorServo.attached() != 1) {
    doorServo.attach(servoPin);
    delay(10);
  } 

 doorServo.write(closedPosition);
  doorIsOpen = LOW;
}

void loop() {

  //Set LED before opening and closing to see the set position of the toggle
    if(doorIsOpen == HIGH) {
    digitalWrite(led, LOW);
  } else if (doorIsOpen == LOW) {
    digitalWrite(led, HIGH);
  }

  int val = digitalRead(distance);
  if(val == HIGH) {
    if(doorIsOpen == HIGH) {
      //shut door
      closeDoor();
    } else if  (doorIsOpen == LOW) {
      //open door 
      openDoor();
    }

     if(doorIsOpen == HIGH) {
    digitalWrite(led, LOW);
  } else if (doorIsOpen == LOW) {
    digitalWrite(led, HIGH);
  }

  //delay allowing changes for smoothness and because servo must be continually updated
     int time = 0;
     for(time=0; time < 150; time++) {

       SoftwareServo::refresh();
      delay(40);
    }
    doorServo.detach();
  }



  delay(30); 
  SoftwareServo::refresh();
}

The code for this project can also be found here.

Putting It All Together

After fabrication all of the individual components, I assembled the project. First, I installed the wall anchor and the door connector. Then, I added the structural beams to the anchor and door. Next, I connected them together and actated the door manually. It moved fine, so I attached the servo into the servo bay and actuated the door with an Arduino Uno I had lying around. The servo moved the door when in High-Powered 6 volt mode.

The two power supplies I used were this for high (6V) voltage, and this for low (5V) voltage.

When the circuit testing was complete, I installed the circuit inside the door and hooked up the power, sensor, and servo. I tested the door, and it worked great.

Video of Test
A Video of the Door Opener in Action