Introduction: How to Make 'Despicable Me' Bomb Beds

Picture of How to Make 'Despicable Me' Bomb Beds

IDEA: 

The idea was initiated for an Automata project (a machine with computations) required for our Things That Think class at CU Boulder. 
Our Automaton is taken from the 'Despicable Me' movie, where the girls have bombs for beds and align on top of another when it is time to sleep. 


Input:
LED light, Switch 

Output:
When lights are OFF:
- The beds start moving towards the wall till aligned.
- The girls wake lie down

When lights are ON:
- The beds descending
- The girls wake up by a sitting up motion


Step 1: Material and Tools

- Three (2x2x2) wooden sheets
- A bike chain
- 1 Arduino 
- 1 breadboard
- 3 Servos
- 1 Motor
- 1 DPDT relay
- 2 NPN transistors
- 2 (220 OHM) resistors
- 1 10k OHM resistor
- 1 LDR (light dependent resistor)
- 2 metal rods used as railing
- 3.00mm thick plastic sheet
- A switch
- 3 nerf balls
- Laser cutter
- Drill
- Wood saw machine
- A thick 40 inch tubing
- Fabric for doll making
- LEDs used as lights 

Step 2: The Beds + Dolls

Picture of The Beds + Dolls

Beds: 
For each bed we emptied a nerf ball , curved out parts of it for the U-shaped-holders / mattress and tail. It was all done using a sharp knife and saw, glued via wood glue and sprayed with silver. 
The tail is connected to the back bone of the bed , which was drawn on Adobe Illustrator and cut using the laser cutter. 

Dolls: 
The doll body was made of wooden pieces cut to give it friction when it wakes up, and the girls were made of different fabrics based on personal preference / resources available. 

Step 3: The Rails

Picture of The Rails

Our rails were 4' rods bent at the center and attached to the wall and floor with eye-hooks. The spacing between the rails needs to be the same as the "U" shaped holders of the beds. Hot glue can hold them in place for testing, but eventually it will break so something more permanent is recommended once you complete the project.

Once the rails are formed place a piece of tubing on each. The tubing should be just bigger than the rails so that it can slide on them. You will also want to put some form of lubrication in between the tubing and rails. We used WD-40, but anything to reduce the friction will be fine.

Next connect the U-shaped-holders to the tubing by putting the tubes through the bottom eye hooks. Put the two end holders as close to the ends of the tubing as possible and center the third. Now is a good time to put the beds on the holders and test the motion of the tubing up the curving in the railing. The beds need to be far enough apart they don’t run into each other as they go up the curve.  Once everything is spaced properly glue the holder to the tubing.

Step 4: Children Waking Up

Picture of Children Waking Up
After we have created the beds and the children we need to program them to sit up when the lights turn on and lay down when the lights go out.

We can do this with relatively simple circuits using the popular Arduino. You can get some good tutorials at ladyada.org or arduino.cc.  The code is a mix between the basic light sensor detection and the simple servo movement. It can be found below. A note about the code below. We got two different sized servos, for some reason the movement of these is different so a modified range for the smaller servo needed to be used. The important thing is the servo moves from horizontal to vertical. This may mean you need to either play with the values in the code or the actual position of the servo arm.

Demo: 



Code: 

#include <Servo.h>
#include <stdio.h>

//servo stuff
Servo myservo;  // create servo object to control a servo
               // a maximum of eight servo objects can be created
Servo smallservo;
int pos = 0;    // variable to store the servo position
int wakeUp = 0; // variable to say if kid should be up or not 0: down 1: up

//light stuff
int val = 0;       // variable to store the value coming from the sensor
int count;

void setup()
{
  Serial.begin(9600);  
  //servo stuff
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  smallservo.attach(13);
  pos = 110;

  count = 0;
  //light stuff
  pinMode(A2, INPUT);       // declare the LDR as an INPUT
}

void loop()
{
  count++;
  //sit up in bed
  if(wakeUp == 1)
  {
    for(pos; pos < 179; 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'
      smallservo.write(pos-70);
      delay(15);                       // waits 15ms for the servo to reach the position
    }
  }
  //lay down
  if(wakeUp == 0)
  {
    for(pos; pos>=110; pos-=1)     // goes from 180 degrees to 0 degrees
    {                               
      myservo.write(pos);              // tell servo to go to position in variable 'pos'
      smallservo.write(pos-70);     
      delay(15);                       // waits 15ms for the servo to reach the position
    }
  }
  // light sensor stuff
  val = analogRead(A2);
  Serial.print("light value = ");
  Serial.println(val);
  if(val > 800) //change based on ambient light levels
  {
    wakeUp = 1;
  }
else
{
   wakeUp = 0;
}
delay(1000);
}

Step 5: Beds Moving

Picture of Beds Moving
In order to move the actual beds up and down the track we used a gear motor attached to a bike chain. We wire the motor to the move before and after the children move. Because the beds go up and down we need the motor to run forwards and backwards. In order to get this working we need to use a relay to switch the power.

We referenced an instructible at https://www.instructables.com/id/Super-Easy-Reversible-Motor-Control-for-Arduino-/step2/Schematic-and-Theory-of-Operation/ to wire and get this aspect working. We initially were using a 9v battery and some transistors but they didn’t provide enough current.
I would recommend getting the same transistors they use on the instructible. We then modified our code to include the gear motor movement.

Note that the motor we originally were using did not turn out to be powerful enough for this particular project. This motor might work if your beds are smaller/lighter/... or if you use some type of pulley system where you are only using the motor to aid in the movement and not actually produce all of the movement. We were then forced to start over and use a much stronger stepper motor.

Demo: 




The instructions and code for that is listed below:

void move(int up)
{
  if(up == 1)
  {
    for(int i = 0;i < STEPS;i++)
    {
      digitalWrite(BlackGreenPin, HIGH);
      delay(stepDelay);                 
      digitalWrite(RedBluePin, LOW);   
      delay(stepDelay);                 
      digitalWrite(BlackGreenPin, LOW);
      delay(stepDelay);
      digitalWrite(RedBluePin, HIGH);
      delay(stepDelay);
    }
  }
  else if(up == 0)
  {
    for(int i = 0;i < STEPS;i++)
    {
      digitalWrite(BlackGreenPin, HIGH);
      delay(stepDelay);                 
      digitalWrite(RedBluePin, HIGH);   
      delay(stepDelay);                 
      digitalWrite(BlackGreenPin, LOW);
      delay(stepDelay);
      digitalWrite(RedBluePin, LOW);
      delay(stepDelay);
    }
  }
}

Step 6: Extras

Picture of Extras

Lights and Switch
We added lights attached to a switch to set off the LDR. However, the simple LEDs we used were not strong enough to demonstrate with other ambient light so the room would have needed to be completely dark. If you would like to use stronger lights then by all means be my guest.  The switch and light system is very simple to set up. You can either attach it directly to a battery and bypass the arduino all together or you can use the following simple light switch code listed below and run everything through your arduino.

Step 7: Full Code

#include <Servo.h>
#include <stdio.h>


Servo bigServo;
Servo smallServo;
int SmallServoPin = A13;
int BigServoPin = A15;
int pos = 0;
int wakeUp = 0;
int moveBeds = 0;
int lightChange = 0;
int val = 0;
int count;
int time;
int BlackGreenPin = 24;
int RedBluePin = 22;
int lightThreshold = 500;
int STEPS = 70;
int stepDelay = 100;

void setup()
{
  Serial.begin(9600);
  bigServo.attach(BigServoPin);
  smallServo.attach(SmallServoPin);
  pos = 110;
  count = 0;
 
  //pin controls
  pinMode(BlackGreenPin, OUTPUT);
  pinMode(RedBluePin, OUTPUT);
  pinMode(A2, INPUT);
}

void loop()
{
  //Serial.println(Serial.list());
  Serial.println();

  val = analogRead(A2);
  Serial.print("light value = ");
  Serial.println(val);
  if(val > lightThreshold)
  {
    wakeUp = 1;
    if(lightChange == 1)
    {
      moveBeds = 1;
      lightChange = 0;
    }
  }
  else
  {
    wakeUp = 0;
    if(lightChange == 0)
    {
      moveBeds = 1;
      lightChange = 1;
    }
  }
 
  if(wakeUp == 0)
  {
    for(pos; pos >= 110; pos -= 1)
    {
      bigServo.write(pos);
      smallServo.write(pos-70);
      delay(15);
    }
    if(moveBeds == 1)
    {
      moveBeds = 0;
      move(0);
    }
  }
 
  if(wakeUp == 1)
  {
    if(moveBeds == 1)
    {
      moveBeds = 0;
      move(1);
    }
    for(pos; pos < 179; pos +=1)
    {
      bigServo.write(pos);
      smallServo.write(pos-70);
      delay(15);
    }
  }
 
  delay(1000);
 
}

void move(int up)
{
  if(up == 1)
  {
    for(int i = 0;i < STEPS;i++)
    {
      digitalWrite(BlackGreenPin, HIGH);
      delay(stepDelay);                 
      digitalWrite(RedBluePin, LOW);   
      delay(stepDelay);                 
      digitalWrite(BlackGreenPin, LOW);
      delay(stepDelay);
      digitalWrite(RedBluePin, HIGH);
      delay(stepDelay);
    }
  }
  else if(up == 0)
  {
    for(int i = 0;i < STEPS;i++)
    {
      digitalWrite(BlackGreenPin, HIGH);
      delay(stepDelay);                 
      digitalWrite(RedBluePin, HIGH);   
      delay(stepDelay);                 
      digitalWrite(BlackGreenPin, LOW);
      delay(stepDelay);
      digitalWrite(RedBluePin, LOW);
      delay(stepDelay);
    }
  }
  else
  {
    Serial.print("Error in move function. Unexpected value - ");
    Serial.println(up);
  }
}

Comments

About This Instructable

14,521views

7favorites

License:

More by Hawra:Simon the OctopusHow to Make 'Despicable Me' Bomb Beds
Add instructable to: