The Moving Door

The project is called "The Moving Door." I created this project to let people hide small and valuable items. By placing your hand near a ultrasonic distance sensor and my servo motor will turn 175 degrees and the door will turn. Once you remove your hand the door will close.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Parts/Materials

1. Arduino

2. Ultrasonic distance sensor

3. Wires

4. Alternative power supply

5. Servo motor

6. Cardboard

7. Glue

8. USB cable

Step 2: Code

#include

const int echpin = 4

const int trigPin = 2;

Servo myservo;

int pos = 0;

void setup() {

myservo.attach(8);

Serial.begin(9600);

pinMode(2, OUTPUT);

pinMode(4, INPUT);

while(! Serial);

Serial.println("speed 0 to 225"); }

void loop() {

long duration, inches;

delay(15);

digitalWrite(2, LOW);

delayMicroseconds(2);

digitalWrite(2, HIGH);

delayMicroseconds(5);

digitalWrite(2, LOW);

duration = pulseIn(4, HIGH);

inches = duration / 74 / 2;

Serial.println(inches);

delay(200);

if (inches < 5) { for (pos = 0; pos <= 180; pos += 1)

myservo.write(pos);

delay(15); }

if (inches > 5) { for (pos = 180; pos >= 0; pos -= 1)

myservo.write(pos);

delay(15);

}

}

Step 3: Setup

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    3 Discussions

    None
    Swansong

    1 year ago

    That's a fun class project, I hope you get an A :)