Smart Box

Hey!

This is a small project I made for school and its quite simple but fun!

The box will open with a fun little drawing if the sensor sees something close by. I hope this can help!

Step 1: Wiring, Schematic and Code

You will need a Breadbord

A servo motor

A ultrasonic Sensor

An Arduino (Uno, nano)

And wires.

The code:

#include

Servo myservo; const int servo_pin = 2; const int trig_pin = 3; const int echo_pin = 4; const int inter_time = 200; int time = 0;

void setup() { Serial.begin(9600); myservo.attach(servo_pin, 500, 2400); myservo.write(90); pinMode (trig_pin, OUTPUT); pinMode (echo_pin, INPUT); delay(3000); }

void loop() { float duration, distance; digitalWrite(trig_pin, HIGH); delayMicroseconds(1000); digitalWrite(trig_pin, LOW); duration = pulseIn (echo_pin, HIGH); distance = (duration/2)/29; Serial.print(distance); Serial.println(" cm"); time = time + inter_time; delay(inter_time); if (distance < 10) { for(int i = 1500; i >= 1100; i-=25){ myservo.writeMicroseconds(i); Serial.println("2"); delay(100); } delay(1000); for(int i = 1100; i <= 1500; i+=25){ myservo.writeMicroseconds(i); Serial.println("1"); delay(100); } } }

Step 2: Putting It Inside the Box.

You will need cardboard so you can cut your box from it. Decide for yourself how big its going to be, it doesn't really matter as long your whole arduino plus wires fits in.

Now that you have your box. Look for the middle in the front and cut two holes in it, your ultrasonic sensor will go here. I sticked my breadboard to the side (Picture 1) so it fits nicely and I taped my Arduino to the other side on the bottom. Now place your servo motor so that it will actually lift up the lit. Now, glue everything together and you are done!

You can choose to use a Battery V9, or do it with your computer, if the last one is the case, you have to cut a hole for the wire under the holes for the sensor.

Step 3: Enjoy

Enjoy your own little box! You can design it the way you like it! This is just the basic

Share

    Recommendations

    • Epilog X Contest

      Epilog X Contest
    • Remix Contest

      Remix Contest
    • Faux-Real Contest

      Faux-Real Contest

    Discussions