loading

Hello everyone!

In this instrutable, I'd like to tell you all about a school project of mine called If This Then That (ITTT for short). I'd like to tell you what I've made, why and how.

I have made a box. From the holes and scratches you can see the light flicker omniously. You can hear the sounds of gears and metal cracking. You can feel the box vibrating. All to make one wonder: what's inside? Expect nothing, for you will recieve nothing. Peeking inside this box will be rewarded with mere dissapointment. The box may seem intriguing from the outside, but just as you can't sustain your curiosity any longer and take a peek inside, all expectations and hopes will disappear in the nothingness that is the content of the box.

So, why did I make it? Basically just for the heck of it. It can easely function as the main object in a hidden camera prank. Put it in a public space somewhere and people will be intrigued and maybe even worried. When peeking in the box they'll realize all their thoughts and worries were for nothing. Don't judge a book by it's cover.

Now, I will explain step by step how I came up with this idea and how I had put it all together.

Things I used for my project:

  • 1 arduino
  • 1 solderless breadboard
  • 4 5mm LED lights; 2 red, 2 orange
  • 1 servo
  • 1 LDR sensor
  • 2 resistors; 1 220 Ohm and 1 16 kOhm
  • 1 USB Cable
  • 1 Metal plate
  • multyple small metal objects (screws and bolts)
  • (at least) 17 cables

Step 1: Brainstorming

After seeing some examples of what you could do with arduino, I have seen many examples of arduino that moved people to stop with whatever they were doing and interact with the arduino. A curtain moving along with the people passing it for example. This appealed to me the most so I wanted to make something that would somewhat do the same. Then the idea of some sort of pandora box began to rise. Not only did I find this a fun idea, it was also a great way to experiment with arduino. I could expend my box with whatever I wanted, which made it a great opportunity to experiment with Arduino.

Step 2: Flickering Lights

The first and most simple thing to do to make the box more noticable is to make light flicker from it. In your arduino IDE, go to examples>Basics>blink and you basically got the code I used for the flickering lights. I did change the code a bit to randomize the delay and speed of the blinking and because I had a different digital input, so:

Instead of:

<p>// the setup function runs once when you press reset or power the board<br>void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}</p><p>// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}</p>

I used:

<p>// the setup function runs once when you press reset or power the board<br>void setup() {
  // initialize digital pin 11 as an output.
  pinMode(11, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {</p><p>//the light flickers omniously</p><p>  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(random(25, 100));              // wait for 25 ~ 100 nano seconds</p><p>  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(random(25, 100));              // wait for 25 ~ 100 nano seconds
}</p>

Now implement all the leds you need. Your board now should look something like this.

Step 3: Making Sound

It was a bit of a quest to determine what would be an appropriate sound to lure people to the box. I learned that metal was the absolute winner. I gathered a metal plate and some small scraps and bolts, and made the servo run like a lunatic on it. Also in this step I included code you can find as samples in your Arduino IDE. Go to examples>servo>sweep and there you have it. I changed the delay again from 15 to 0.5 to make the sound more present, like an alarm clock ringing. This also affected the blinking of the lights, since I used the command delay which affects the whole lot of arduino. To still randomize the blinking I used the command millis. the code shows the changes I've made.

I now used this piece of code for the blinking instead of what i did in step 2:

<p>unsigned long currentMillis = millis();<br> 
    if(currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED 
      interval = random(25, 100);
      previousMillis = currentMillis;   </p><p>    // if the LED is off turn it on and vice-versa:
      if (ledState == LOW)
        ledState = HIGH;
      else
        ledState = LOW;   
  }</p>

And I changed the Servo code to this:

<p>#include  <br> 
Servo myservo;  // create servo object to control a servo 
                // twelve servo objects can be created on most boards
 
int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
 
void loop() 
{ 
  for(pos = 0; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(0.5);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=0; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(0.5);                       // waits 15ms for the servo to reach the position 
  } 
}</p>

Notice how I only changed the delay compare to the example code.

Your board now looks somewhat like this:

Just attach the servo loosely to the metal plate and put the screws and bolts on it and you're in for some really annoying sounds!

Step 4: Into the Darkness

Now we've got it all working, but the whole meaning of this was to only let it work when the Box is closed. That's where the LDR comes in. Here we see it attached to our board:

As you can see in the code editor, all we need to do now is nest the code we had up till now in an if statement. Then change the amount of voltage to low, and then when the light hits the sensor, everything will stop working. When it's dark again everything will start working again. Play a little with the sensitivity here based on how bright your surroundings are.

Step 5: Implementation

If you've managed to follow my somewhat imrpovised tutorial up till now and got all the software and hardware working I'm amazed as well as going to tell you the very last step: putting all of this in the box. Make sure the box is big enough to place your arduino in and deep enough to have some space still left. I have found this rituals box for example. I made holes and scratches in the box; 1 hole for the cable, 1 hole for the LDR and the other holes and scratches for the light to be visible from outside of the box. I made the hole for the LDR in the bottom left corner of the box so that the LDR will detect the light almost immediately after the box is opened; and it still remained surprisingly unnoticable for the people that were using the box. Now that we made the box arduino proof let's nest everything we've made inside it. But there is still something missing. It's hard to not notice the arduino responsible for making the noise and lights when opening the box. So, we're gonna need an extra layer. Cut some cardboard equivalent to the surface of the box and put some black paper around it. Now you have your own double layered box.

Step 6: Completion!

When you've uploaded the code you're ready to mess with people! when all is well, it should look something like this:

Congratulations! You've endured my tutorial! Go get some pizza you've earned it!

<p>Very cool project. You should enter this into some of the contests that are currently running.</p>

About This Instructable

2,644views

19favorites

License:

More by LennertK:If This Then That - The Box 
Add instructable to: