Introduction: How to Build Another Useless Machine: Easy to Make, and Hard to Use!

Picture of How to Build Another Useless Machine: Easy to Make, and Hard to Use!

So many useless machines are built, why building another one? Simply, it is really fun :), fun to build and fun to play with.

I tried to give this version a character, as I always felt there is somebody  "thinking inside the box", so here I tried, I hope I succeeded to give "her" a life!

I am really happy to share with you all the steps, with all hopes that you will be easily building yours and giving it a bitter or better character! My version is based on Arduino, you may think it is an overkill, but given the flexibility it gave me, I think it is worth it.

Here is a video of everything  put all together. Later, we will move into the parts, steps, schematics and code

Let me know your comments and/or questions if any.

Hope you enjoy!
f.

Step 1: How It Works?

Everything is connected to an Arduino board, the board waits till the switch is set to logic HIGH , that is, when you flick the switch, the board signals two servo motors to move in a specific way (more on that later), after which, the servo connected to the "hand" will flick the switch back to OFF-position, and return back into the box, followed by the "door" servo. then everything repeats.

If you saw the above video, each time the switch is toggled, the machine responds in a different way, and this is done by simply writing different functions with different timings in the Arduino code, (I am calling them "Moves"). Each time the switch is toggled, I am calling a new move until all are done, I start over. note that in step 9, I provided another version of the code that picks random moves instead of sequential. You can add as many moves as you want, as long you have enough memory on the Arduino.

The Arduino is always ON, this is why I added a switch for the battery to save some power when the machine is not in use. I am already planning to use an interrupt on the switch, instead of the current simple HIGH/LOW detection, and coupling it with sleep mode. This shall save power when the machine is not in use ,and also allowing it to be always ready (but this will also complicate the code) So, for now, it is just a simple ON/OFF switch, and the board is always powered.

Step 2: The Parts

You will need:

Mandatory:

1. A box 
2. Any Arduino board with PWM outputs (I happen to have an old one laying around, the Diecimila)
3. Two standard RC servo motors (I used the Futaba - S3003, they have 3,2 Kg/cm torque, more than enough to move the door or hand)
4. A 6-12 V battery (I used my AR drone battery, it is a 11.1 v / 1000 mA) 
3. An SPTT or SPST switch for the trigger (basically, any switch that suits you!)
5. Another switch for the battery
6. A push button to reset the Arduino in case you want to restart the moves/code from top.
7. Some jumper wires


Optional:

In case you want to design a move that includes moving the box around (like last move in the video), then you can get:

1. An Arduino motor shield, this will also be handy for other projects (or you can design an H-bridge yourself, search it out)
2. A cheap RC car so you can take its DC motor and gear box

Furthermore, still in the "optional" section, I've built a hardware de-bounce circuit to have a clean trigger when the switch is toggled on/off. This can be skipped and easily be implemented in arduino software using delays or timers. I did the hardware debounce because I will be soon changing the code to use interrupts, and since the latter do not allow the reliable use of delay/timer functions in the routine, so I had to build a simple de-bounce circuit for future use. If you want to skip this part, then  just connect a simple switch/resistor to pin 2 of the arduino and implement a software debounce routine.

For the hardware debounce:

1. 10mF electrolytic capacitor
2. 10K resistor
3. A logic NOT gate i.e Inverter (chip 74HC04) This has six inverters, but you will only need one.

Let's build it...

Step 3: Building the Box

Picture of Building the Box

You can use any box you find suitable. I built mine, maybe not perfect, but still much personal :)

1. I used 2 sheets of 5mm BALSA wood, very easy to work with using a cutter, and relatively strong given its incredible light weight.
2. Consumed 5 tubes of Cyanoacrylat glue (aka strong fast-acting adhesives)

Here it is:

A 22 x 14 x 14 cm box

Step 4: Schematic

Picture of Schematic

Above is the schematic (drawn using Fritzing), showing:

Top part: The arduino main board ,2 servos and switch connectivity. Note that as mentioned previously you can replace the whole debounce (top-right) circuit with a simple resistor/switch.

Both "door" and "hand" servos are powered directly from the 5v pin on the Arduino. The signal wires are connected to pin 9 and 10 respectively. These pins supports PWM, thus I am using them to control the angle/position of the servo (from 0 to 180 degree max).

Note: the red push button is just a reset (similar to the one found on the face of the arduino board). I added it to have quick access to reset the board/software at any time without opening the box. Simply connects the RESET pin to Ground to make the reset.  

Bottom part: needed if you want to use a DC motor and move the machine around. This is the arduino motor shield, it is mounted on top of the Arduino, so all of the pins of both boards are connected to each other. I am showing them below as separated just for clarity, hopefully! This shield can control up to 2 DC motor (2 channels A/B) with incredible ease. I am using only one now. It allows to set in the code, the direction, speed and breaks of any of the available 2 channels/motors. I am using channel B as shown bellow. where pin 
13 for direction, pin 11 for speed and pin 8 for brakes control.

The battery is a 11.1 / 1000 mA, connected to the shield, thus feeding the DC motor , the main arduino board and the servos. if you are not using the shield, then you can directly connect the battery to the power barrel on the main arduino board.


Step 5: Fixing the Servos

Picture of Fixing the Servos

Here is the hand and door servos installed:

You need first to install the servos in their correct places, this needs a bit of trial and error until you get the needed movement. You can use the Servo example provided in the arduino IDE in order  to test the servos and the amount of deflection needed for each, and thus decide on the final positioning and arms length for the door and hand servos.

The arms are simply made from balsa wood, I made them thicker to withstand some tearing.

Below is how I did it. Just one note about the hand servo. You will need the servo shaft to be directly under the edge of the cover (as shown below), this to avoid having hard time in making a hand that can successfully hit the switch, and also be able to go back into the box.




Step 6: Connecting the Switch, Servos and Arduino

Picture of Connecting the Switch, Servos and Arduino

Make all the connections seen in the schematic step, and try to put all inside the box similar to what's shown above:



Step 7: Optional: the DC Motor and Battery

Picture of Optional: the DC Motor and Battery

Above is how I put the DC motor gear box (taken from a cheap RC car), also showing the batter and switch placement.

Make sure to place the gear as centered as possible to balance the box, you may need to put some weight inside the box to balance it more after final assembly, as the battery I used is a bit heavy (100 gr) and caused some wiggling when switching or moving the box. 

Note that the dc motor speed is controlled by pin 11, Direction by pin 13, and brakes on pin 8, these are considered channel B on the arduino motor shield.

Through out the assembly I tried to hide all wires switches and other components in order to have a simple authentic box. This applies to the wheels, so I made a rim around them that hosts both the wheels and battery, and also provides access to the red reset button.

Step 8: The Code

In order to write code for arduino, you need the arduino IDE (download it here)

I am using the version 1.0.5, just make sure to select the correct COM port (windows) and board type from within the IDE, then use the below code, and hit upload.

NOTE: The values I used in the code to set the max deflection of the servos are made exactly for this box taking in account the servos positioning, axis and angles. I got this through trial. So you need to devise your own values according to your box and servo placement.

For reference, below are the min/max values I used for each servo as you will see them occurring in the code:

The door:
80 hiding, 155 fully open

The hand: 
0 hiding, 129 pushing on switch


Here is the code (Better to download the file attached to this step instead of copy/paste from below):

#include <Servo.h>
Servo doorServo;
Servo handServo;

int switch_pin = 2;               //set switch on pin 2

//motor variables
int motorThrottle=11;
int motorDirection = 13;
int motorBrake=8;

int pos = 0;
int selectedMove = 0;             //move selector
int Testmove = 0;                 //test mode: set to move number to test only one selected move
                                  //(set to Zero to run normally i.e: roundrobbin on amm moves)

void setup()
{
  Serial.begin(9600);
  pinMode(switch_pin, INPUT);
  doorServo.attach(9);           //set door servo on Pin 9 pwm
  handServo.attach(10);          //set hand servo on Pin 10 pwm
  doorServo.write(80);           //set door to hiding position
  handServo.write(0);            //set hand to hiding position
 
  //Setup Channel B, (since Channel A is reserved by door and hand servos and can't ber used at same time)
  pinMode(motorDirection, OUTPUT); //Initiates Motor Channel B pin
  pinMode(motorBrake, OUTPUT); //Initiates Brake Channel B pin
 
}


void loop()
{
if (Testmove != 0) {
selectedMove = Testmove;
}
 
  //if the switch is on, then move door and hand to switch it off...
  if(digitalRead(switch_pin) == HIGH)
  {
   
  if (selectedMove > 10) { selectedMove = 0; } //when all moves are played, repeat the moves from beginning
  // below are all the "Moves" i designed so far, each is a function that is written below in the code, execuse the names, abit strange? yes as some are written in arabic
  if (selectedMove == 0) { switchoff(); }
  else if (selectedMove == 1) { switchoff(); }  
  else if (selectedMove == 2) { switchoffbitaraddod(); }
  else if (selectedMove == 3) { crazydoor(); }
  else if (selectedMove == 4) { crazyslow(); }
  else if (selectedMove == 5) { m7anika7anika(); }
  else if (selectedMove == 6) { m3alla2(); }
  else if (selectedMove == 7) { switchoff(); }
  else if (selectedMove == 8) { matrix(); }
  else if (selectedMove == 9) { sneak(); }
  else if (selectedMove == 10) { zee7(); }
  
  if (Testmove == 0) {
  selectedMove++;         //swith to next move if not in test mode
  }

}
}



// Library of moves

   // basic move
   void switchoff()
   {   
   //Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
  
    //Moving hand
    for(pos = 0; pos < 129; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    } 
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
   }
    
   // move 3: open and wait, then move hand and wait, then switch of and hide 
    void switchoffbitaraddod()
   {
  //Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    delay(800);
    //Moving hand
    for(pos = 0; pos < 100; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }
    delay(1000);
    for(pos = 100; pos < 129; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }   
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=5)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                   
    
    
   }
    
   }
 
   //move 4: open door then close it many times, wait, then quickly reoprn a nd switch off and hide.
 
   void crazydoor()
  {
   
   //Moving door
    for(pos = 80; pos < 125; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
 
    //hiding door
    for(pos = 125; pos>=80; pos-=5)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
   //Moving door
    for(pos = 80; pos < 110; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
 
    //hiding door
    for(pos = 110; pos>=80; pos-=15)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
    delay(700);
   //Moving door
    for(pos = 80; pos < 125; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    delay(700);
    //hiding door
    for(pos = 125; pos>=80; pos-=5)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }

   
    //----of switch of----//
  //Moving door
    for(pos = 80; pos < 155; pos = 8)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
  
    //Moving hand
    for(pos = 0; pos < 129; pos = 3) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    } 
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=3)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=15)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }   
   
  }  


// move 5: open door, then move hand very slowly forward and back to hiding very slowly, then quickly close door
void crazyslow()
{

//Moving door
    for(pos = 80; pos < 155; pos = 1)  
    {                                  
    doorServo.write(pos);             
    delay(30);                      
    }
  
    //Moving hand
    for(pos = 0; pos < 129; pos = 1) 
    {                                  
    handServo.write(pos);              
    delay(30);                      
    } 
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=1)     
    {                               
    handServo.write(pos);              
    delay(30);                       
    }
     
    //hiding door
    for(pos = 155; pos>=125; pos-=1)    
    {                               
    doorServo.write(pos);             
    delay(30);                     
    }
    delay(100);
    for(pos = 125; pos>=80; pos-=4)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }    
   

}

//move 6:

void m7anika7anika() {

//Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    
    //Moving hand
    for(pos = 0; pos < 70; pos = 1) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }
    delay(800);
   
   
    //hiding door
    for(pos = 155; pos>=130; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);
    }
   
    //hiding door
    for(pos = 130; pos < 155; pos =3)    
    {                               
    doorServo.write(pos);             
    delay(15);
    }
     //hiding door
    for(pos = 155; pos>=130; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);
    }  
    //hiding door
    for(pos = 130; pos < 155; pos =3)    
    {                               
    doorServo.write(pos);             
    delay(15);
    }
    
    handServo.write(40);
    delay(1000);
     
    //Moving hand
    for(pos = 40; pos < 129; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
   
     
    for(pos = 120; pos>=80; pos -= 1)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
  
  
    
}

void m3alla2(){
//Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
  
    //Moving hand
    for(pos = 0; pos < 127; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }
    //hiding door
    for(pos = 155; pos>=130; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }  
    delay(2000);
   
    for(pos = 130; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
   
    for(pos = 155; pos>=140; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);
    }
    for(pos = 140; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    delay(500);
    //hiding hand
    for(pos = 127; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }

}
  
void matrix()
{

//Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
  
    //Moving hand
    for(pos = 0; pos < 80; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }
   
    for(pos = 80; pos < 129; pos = 1) 
    {                                  
    handServo.write(pos);              
    delay(30);                      
    } 
    delay(300);
   
    for(pos = 129; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(10);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
 
}

void sneak()
   {   
   //Moving door
    for(pos = 80; pos < 130; pos = 1)  
    {                                  
    doorServo.write(pos);             
    delay(30);                      
    }
    delay(2000);
   
    //Moving hand
    for(pos = 0; pos < 40; pos = 1) 
    {                                  
    handServo.write(pos);              
    delay(30);                      
    } 
       
    delay(500);
   
    for(pos = 130; pos < 155; pos = 4)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    delay(100);
   
    for(pos = 40; pos < 90; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    } 
    delay(500);
    //hiding hand
    for(pos = 90; pos>=70; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
    delay(100);
    for(pos = 70; pos < 90; pos = 4) 
    {                                  

    handServo.write(pos);              
    delay(15);                      
    }
    delay(100);
    for(pos = 90; pos>=70; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
    delay(100);
      
    for(pos = 70; pos < 129; pos = 4) 
    {                                  

    handServo.write(pos);              
    delay(15);                      
    }
   
    for(pos = 129; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }   
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
   }
  
  
   void zee7()
   {   
   //Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
   delay(2000);
   //forward @ half speed to the left 
   digitalWrite(motorDirection, LOW); //Establishes RIGHT direction of Channel B
   digitalWrite(motorBrake, LOW);      //Disengage the Brake for Channel B
   analogWrite(motorThrottle, 100);    //Spins the motor on Channel B at full speed
   delay(300);
   digitalWrite(motorBrake, HIGH); //Eengage the Brake for Channel B
   delay(2000);
  
   //backward @ half speed to the right
   digitalWrite(motorDirection, HIGH); //Establishes LEFT direction of Channel B
   digitalWrite(motorBrake, LOW);   //Disengage the Brake for Channel B
   analogWrite(motorThrottle, 100);   //Spins the motor on Channel B at half speed
   delay(300);
   digitalWrite(motorBrake, HIGH); //Eengage the Brake for Channel B
   delay(1000);
 
    //Moving hand
    for(pos = 0; pos < 129; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    } 
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
   }




Step 9: Optional Update: Movement Detection

Picture of Optional Update: Movement Detection
I've got a proximity sensor today (GP2Y0A21), so now I can use it to move the machine if the user approaches the toggle switch :)

For this additional step, I am assuming you've already built the wheels to allow movement (see optional step 8). All what is left now is to add the sensor and make some modifications in the code for movement detection.

The sensor has 3 wires, yellow signal wire connected to pin 3 on arduino, while the red and black are connected to v5 and ground respectively on the board.

I've placed the sensor hidden under the door as shown in the picture, thus it can 'see' the user's movement only when the door opens. exactly what I need!

I had also to change the code a bit (here) to implement a movement detection routine (see the code, in function zee7()), such that when movement is detected, the box will move, first to the right, then to the left, then the hand flips the switch and hide. The code is heavily commented, I hope I didn't overdo it!

You can find the updated code below, also note that I've made the machine picks the moves randomly, this can be changed back to sequential by simply setting boolean randomize = false;

Thanks ALL for your great suggestions!

The code (Better to download the file attached to this step instead of copy/paste from below):

#include
Servo doorServo;
Servo handServo;

unsigned long TimerA,TimerB;       //timer for the movement detection routine
int switch_pin = 2;               //set switch on pin 2

//motor variables
int motorThrottle=11;
int motorDirection = 13;
int motorBrake=8;

//Distance Variables
int motionPin = 3;               //motion sensor pin on analog 0
int lastDist = 0;                //to remember last distance
int currentDist = 0;  
int thresh = 200;                //Threshold for Movement (set it such that you get the desired sensetivity of motion detection)


int pos = 0;
int selectedMove = 0;             //move selector
int Testmove = 0;                 //test mode: set to move number to test only one selected move
                                 //(set to Zero to run normally i.e: roundrobbin on all moves)
boolean randomize = true;        // if true, the box will do movers randomly, if set to false then the moves will be done sequencially from 1 to 10


void setup()
{
  Serial.begin(9600);
  pinMode(switch_pin, INPUT);
  doorServo.attach(9);           //set door servo on Pin 9 pwm
  handServo.attach(10);          //set hand servo on Pin 10 pwm
  doorServo.write(80);           //set door to hiding position
  handServo.write(0);            //set hand to hiding position
  //Setup Channel B, since Channel A is reserved by door and hand servos and can't ber used at same time
  pinMode(motorDirection, OUTPUT); //Initiates Motor Channel B pin
  pinMode(motorBrake, OUTPUT); //Initiates Brake Channel B pin
 
}


void loop()
{

  //if the switch is on, then move door and hand to switch it off...
  if(digitalRead(switch_pin) == HIGH)
  {
   
  if (Testmove == 0)
  {
     
    if(randomize == false)
    { 
      if (selectedMove > 10)
      {
      selectedMove = 0; //when all moves are played, repeat the moves from beginning
      }
    }
    else
    {
    selectedMove = random(11);
    }
  }
  else
  {
  selectedMove = Testmove;
  }
  Serial.println(selectedMove);
  if (selectedMove == 0) { switchoff(); }
  else if (selectedMove == 1) { switchoff(); }  
  else if (selectedMove == 2) { switchoffbitaraddod(); }
  else if (selectedMove == 3) { crazydoor(); }
  else if (selectedMove == 4) { crazyslow(); }
  else if (selectedMove == 5) { m7anika7anika(); }
  else if (selectedMove == 6) { m3alla2(); }
  else if (selectedMove == 7) { switchoff(); }
  else if (selectedMove == 8) { matrix(); }
  else if (selectedMove == 9) { sneak(); }
  else if (selectedMove == 10) { zee7(); }
  
  if (Testmove == 0 && randomize == false) {
  selectedMove++;         //switch to next move if not in test mode
  }

}
}

// Library of moves

   // basic move
   void switchoff()
   {   
   //Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
  
    //Moving hand
    for(pos = 0; pos < 129; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    } 
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
   }
    
   // move 3: open and wait, then move hand and wait, then switch of and hide 
    void switchoffbitaraddod()
   {
  //Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    delay(800);
    //Moving hand
    for(pos = 0; pos < 100; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }
    delay(1000);
    for(pos = 100; pos < 129; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }   
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=5)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                   
    
    
   }
    
   }
 
   //move 4: open door then close it many times, wait, then quickly reoprn a nd switch off and hide.
 
   void crazydoor()
  {
   
   //Moving door
    for(pos = 80; pos < 125; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
 
    //hiding door
    for(pos = 125; pos>=80; pos-=5)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
   //Moving door
    for(pos = 80; pos < 110; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
 
    //hiding door
    for(pos = 110; pos>=80; pos-=15)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
    delay(700);
   //Moving door
    for(pos = 80; pos < 125; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    delay(700);
    //hiding door
    for(pos = 125; pos>=80; pos-=5)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }

   
    //----of switch of----//
  //Moving door
    for(pos = 80; pos < 155; pos = 8)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
  
    //Moving hand
    for(pos = 0; pos < 129; pos = 3) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    } 
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=3)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=15)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }   
   
  }  


// move 5: open door, then move hand very slowly forward and back to hiding very slowly, then quickly close door
void crazyslow()
{

//Moving door
    for(pos = 80; pos < 155; pos = 1)  
    {                                  
    doorServo.write(pos);             
    delay(30);                      
    }
  
    //Moving hand
    for(pos = 0; pos < 129; pos = 1) 
    {                                  
    handServo.write(pos);              
    delay(30);                      
    } 
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=1)     
    {                               
    handServo.write(pos);              
    delay(30);                       
    }
     
    //hiding door
    for(pos = 155; pos>=125; pos-=1)    
    {                               
    doorServo.write(pos);             
    delay(30);                     
    }
    delay(100);
    for(pos = 125; pos>=80; pos-=4)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }    
   

}

//move 6:

void m7anika7anika() {

//Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    
    //Moving hand
    for(pos = 0; pos < 70; pos = 1) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }
    delay(800);
   
   
    //hiding door
    for(pos = 155; pos>=130; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);
    }
   
    //hiding door
    for(pos = 130; pos < 155; pos =3)    
    {                               
    doorServo.write(pos);             
    delay(15);
    }
     //hiding door
    for(pos = 155; pos>=130; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);
    }  
    //hiding door
    for(pos = 130; pos < 155; pos =3)    
    {                               
    doorServo.write(pos);             
    delay(15);
    }
    
    handServo.write(40);
    delay(1000);
     
    //Moving hand
    for(pos = 40; pos < 129; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }
   
    //hiding hand
    for(pos = 129; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
   
     
    for(pos = 120; pos>=80; pos -= 1)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
  
  
    
}

void m3alla2(){
//Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
  
    //Moving hand
    for(pos = 0; pos < 127; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }
    //hiding door
    for(pos = 155; pos>=130; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }  
    delay(2000);
   
    for(pos = 130; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
   
    for(pos = 155; pos>=140; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);
    }
    for(pos = 140; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    delay(500);
    //hiding hand
    for(pos = 127; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }

}
  
void matrix()
{

//Moving door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
  
    //Moving hand
    for(pos = 0; pos < 80; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    }
   
    for(pos = 80; pos < 129; pos = 1) 
    {                                  
    handServo.write(pos);              
    delay(30);                      
    } 
    delay(300);
   
    for(pos = 129; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(10);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
 
}

void sneak()
   {   
   //Moving door
    for(pos = 80; pos < 130; pos = 1)  
    {                                  
    doorServo.write(pos);             
    delay(30);                      
    }
    delay(2000);
   
    //Moving hand
    for(pos = 0; pos < 40; pos = 1) 
    {                                  
    handServo.write(pos);              
    delay(30);                      
    } 
       
    delay(500);
   
    for(pos = 130; pos < 155; pos = 4)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    delay(100);
   
    for(pos = 40; pos < 90; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    } 
    delay(500);
    //hiding hand
    for(pos = 90; pos>=70; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
    delay(100);
    for(pos = 70; pos < 90; pos = 4) 
    {                                  

    handServo.write(pos);              
    delay(15);                      
    }
    delay(100);
    for(pos = 90; pos>=70; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
    delay(100);
      
    for(pos = 70; pos < 129; pos = 4) 
    {                                  

    handServo.write(pos);              
    delay(15);                      
    }
   
    for(pos = 129; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }   
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
   }
  
   //this move will open the door and wait for movement, if detected near the switch,
   //the box will move first to the Right, and then to the Left, and finally the hand moves and turns off the switch
   void zee7()
   { 
    
   //open door
    for(pos = 80; pos < 155; pos = 3)  
    {                                  
    doorServo.write(pos);             
    delay(15);                      
    }
    delay(1200);    //wait to stabilize sensor readings after opening the door
     
     // set the timer and read the sensor
     // wait for movement that exceeds threshold or if timer expires (5 sec),
     lastDist= analogRead(motionPin);  
     TimerA= millis();
    
     while(millis()-TimerA <= 5000)
     {
        currentDist = analogRead(motionPin);
    
        //Does the current distance deviate from the last distance by more than the threshold?
        //if yes, then move box to the right
        if ((currentDist > lastDist thresh || currentDist < lastDist - thresh) || currentDist > 300)
         {

          //forward @ half speed to the left (choose the speed and the delay
          //(i.e delay(300) according to you box and battery voltage such that the movement throw is desirable)
          digitalWrite(motorDirection, LOW);  //Establishes RIGHT direction of Channel A
          digitalWrite(motorBrake, LOW);      //Disengage the Brake for Channel B
          analogWrite(motorThrottle, 100);    //Spins the motor on Channel B at full speed
          delay(300);
          digitalWrite(motorBrake, HIGH); //Eengage the Brake for Channel B
          break;
          }
     lastDist = currentDist;  
     }
   
      // set the timer and read the sensor
      // wait for movement that exceeds threshold or if timer expires (5 sec),
      delay(1200);  //wait to stabilize sensor readings after opening the door
      lastDist= analogRead(motionPin); 
      TimerB= millis();
      while(millis()-TimerB <= 5000)
      {
        currentDist = analogRead(motionPin);    
        //did the box already move to the right and the current distance deviate from the last distance by more than the threshold?
        //If yes, then move to the Left
        if ((currentDist > lastDist thresh || currentDist < lastDist - thresh) || currentDist > 300)
         {

          //backward @ half speed to the right (choose the speed and the delay
          //(i.e delay(300) according to you box and battery voltage such that the movement throw is desirable)
          digitalWrite(motorDirection, HIGH); //Establishes LEFT direction of Channel B
          digitalWrite(motorBrake, LOW);   //Disengage the Brake for Channel B
          analogWrite(motorThrottle, 100);   //Spins the motor on Channel B at half speed
          delay(300);
          digitalWrite(motorBrake, HIGH); //Eengage the Brake for Channel B
          break;
          }
     
      lastDist = currentDist;  
  
      }
    delay(100);
    //Moving hand
    for(pos = 0; pos < 130; pos = 4) 
    {                                  
    handServo.write(pos);              
    delay(15);                      
    } 
   
    //hiding hand
    for(pos = 130; pos>=0; pos-=4)     
    {                               
    handServo.write(pos);              
    delay(15);                       
    }
     
    //hiding door
    for(pos = 155; pos>=80; pos-=3)    
    {                               
    doorServo.write(pos);             
    delay(15);                     
    }
   }

Comments

areyoutrying (author)2014-11-30

Thanks for this! I made my first Arduino project based on this instructable: a useless dragon!

Ajann (author)areyoutrying2015-10-30

Your dragon machine is awesome. !!! Artistic

TJAOkevin (author)areyoutrying2015-06-23

Awesome!!!!!

riachi (author)areyoutrying2014-11-30

You are awesome :) !!!

Great personality for a Dragon! I wish you can redo the video while having the dragon directly facing the camera (top-view), I feel this will be hilarious, so see the tongue sneaking out!

Thanks for sharing your video and glad my i'able has helped

areyoutrying (author)riachi2014-12-05

I tried top view in an earlier stage but it didn't work (saw too much of the messy insides) so I dismissed it when I took this video. I think you are right though: in the final stage it would've looked great! Unfortunately I already gave the dragon away... So on to the next project!

melton1313 made it! (author)2014-12-31

Code helped a lot. Thanks

riachi (author)melton13132015-01-08

AWESOME!! :) would be great if you an post a video too :)

melton1313 (author)riachi2015-01-09

Thanks
https://www.youtube.com/watch?v=3HPCv-IgJT8

br1pro (author)2014-12-06

Very fun! hard job fixing the servos and design the hand. Thanks for this instructable!

riachi (author)br1pro2015-01-08

Great work man! really nice :) any video?

clincoln (author)2013-10-24

Watch the video on it first then laugh you ass off

TobiasV (author)clincoln2014-11-06

I know I did ! :D

rileyw (author)2014-01-19

Super cool the video made it seem like it had a mind of its own

Elitekilla117 (author)2013-12-23

My useless machine with arduino and riachis code! Made into a tardis from Dr.who. :)

https://www.youtube.com/watch?v=aDs0T52o6-M

riachi (author)Elitekilla1172013-12-24

LOVE IT!!!! :)) really well done man, so happy to see your bombbox alive! I also the dramatization and the music :p just can't stop myself to suggest 3 small modifications if i may:)?

- it would be great to put the machine in standing position, i know that this will make lose the help of gravity to close the door, but a simple solution is to put 2 rubber bands attached to the inside of the door on one side and to the inner side of the box for the other end, this will make the door close when the door servo is closing...check my build steps,you will see the rubber band in Step 6...

- also what about painting the hands in black, it will be more sneaky and slick
! Also the hand tip can be painted in bloody red or decorated with a crazy face or something like that..

- remove the last move as nothing happens in it(supposed to be the one the moves the box) and write your own move...

Nevertheless, forget the suggestions,i loved your machineeee! And thanks for the so many thanks man, please you can reduce them and keep the video focused on the machine :)

Hope your gf liked it!

Elitekilla117 (author)riachi2013-12-24

Hahah Thank you for the compliments :) I actually wanted to do much more to it but because of the time crunch I couldn't fit in a lot of the details i wanted to. I would like to add some color to the arms but didn't have time for those. And I wanted to draw a face on the arm with a sharpie but its already wrapped up and ready to give to her for Christmas. Hehehe. I think she'll love it. I also did want to have it stand up but was afraid the rubber bands would put too much weight on the servos. The door is already pretty heavy. The last move I kept because it keeps you in suspense waiting for it to pop out. Hahaha but I appreciate all the help my friend! Definitely worth it!

chuckletushy (author)2013-10-23

This I have to make...it's awesome

wrs715 (author)2013-10-17

This is the first project I've seen using an Arduino where I thought, "Yeah, that's worth it. Now I have to get one." Fantastic job!

siliconghost (author)2013-10-16

Wow, awesome take on a common project! Love your spin on making it more interesting!

bob3030 (author)2013-10-16

One man's useless device is another's totally awesome, out of this world, we'll thought out, fun to have, coveted by many, useless device. Thanks for your updates to the project. Thanks for posting.

wobbler (author)2013-10-16

Thought 1: Using an Arduino for this is just ridiculous overkill
Thought 2: After watching the video-Using an Arduino for this is just pure genius!

I bow down to your creativity!

stumitch (author)2013-10-15

Thats seriously great! Kind of reminds me of a Wall-E personality. Thanks for such a great project!

gazillabytes (author)2013-10-15

Truly useless! Nice 'ible. I'm inspired and need to build one for my desk. Thanks.

robot797 (author)2013-10-15

PLEASE TAKE MY MONEY
i realy realy want that thing

makendo (author)2013-10-15

Glad I watched the video to the end. It was already entertaining, but the twist was brilliant.

alzie (author)2013-10-15

Ha, i nearly pissed my self watching the vid!
Got some personality.
Way cool, well done.

rpotts2 (author)2013-10-15

Finally! A Christmas present my in-laws will enjoy! I love thus!

jpow (author)2013-10-15

Best useless machine I've seen! It is on my build list... for sure! I have lots of RC stuff, so all I need is an arduino now :)

thanks for sharing!

diy_bloke (author)2013-10-15

fantastic!

lowpro (author)2013-10-15

So awesome!

michaelgohjs (author)2013-10-14

This is useless...
I like it !! ^.^
nice job, like how you make it "come to life"

chaosrob (author)2013-10-14

This is awesome. Can't wait to see all your improvements and (maybe) a new video. This is a great candidate for a halloween candy bowl... thingiee! Instead of physical switch, a photo resistor to detect candy removal. KEWL.... keep it up!

riachi (author)chaosrob2013-10-14

go for it chaosrob! let me know if i can help!

bob3030 (author)2013-10-13

Cool. Very creative adding the "taunting" and "side" moves. You have inspired me to add this to my list of projects . Thanks for posting and sharing.

riachi (author)bob30302013-10-14

Please let me know when you build yours! thanks

Patrick S (author)2013-10-13

I like the personality! Very funny

towerpro (author)2017-11-09

help me, my useless box dont's working

huntleybill (author)2017-10-11

I don't suppose I will get an answer to this as it is an old post, but I don't
understand the debounce circuit. It looks like you have a direct short.You have a wire going from 5V (it is VERY hard to read this drawing) to the resister then to the capacitor and then directly to ground. Can you please clarify this OR can someone draw how the switch is wired without the debounce circuit.

Thank you

TreyH17 (author)2017-04-06

I'm new to Arduino and jumped on this project. Is there a way to reverse the direction of the hand servo in the code? Any help would be appreciated.

ion-h (author)2016-12-18

Hi Riachi,

I'm attempting this very nice build as my first 'proper' arduino project -- just the simple version (no fancy motion sensors or movement). Everything now good with the electronics, but...

The first cheap servos i used (TowerProSG90) just didn't have the strength to throw the switch (and the switch doesn't offer a lot of resistance). These servos worked well driven off the USB port, or with a pack of 4AA batteries.

So i upgraded my servos to Proster MG 996R. This had two bad effects:

(i) With the SG90, the switch didn't actually need to be thrown to complete the "switch-off" cycle -- very handy while testing. But with the MG996R, everything keeps cycling until the switch is actually turn off. This seems pretty weird to me -- i don't understand why just switching servos should do this.

(ii) Works okay off the USB port, but just nothing with the 4xAA battery pack, nor with a 9V battery.

I know these are very vague observations, but I wondered if you had any comments that might help me make progress -- i'd really like to avoid buying a super expensive battery if possible (my original budget was 30 euros and i've already completely blown that!).

Thanks (for your attention and for the project)

ian

DanialS5 (author)2016-07-20

Hello riachi

Thank you so much for your great tutorial.
I have trouble in my useless machine. My servo can't turn off the switch. How can increase the power?( I am using MG9S right now)

AndyC159 (author)DanialS52016-09-06

I'm using an SG90 which is the plastic version of your one, I had the same problem. I don't think you can increase the power but you can make the switch easier to toggle by opening it and heating the spring inside.

DanialS5 (author)AndyC1592016-09-06

Thnx

AndyC159 made it! (author)2016-09-06

Thank you so much! Fun project.

NikosD1 (author)2016-08-18

Hey!
I found a servo with Stall Torque 1.5kg/cm (5V).
Can I use it?

ShRTee (author)2016-07-20

Hello from Sweden and Thank You for i nice build.

Im not very good with Arduino and was wondering if a Arduino Nono will work with this project ??

Anhl22 (author)2016-05-31

Could you please explain about the switch. I really dont know how to do it.

SamL84 made it! (author)2016-05-04

Hi !!! I from france and I would to build this amazing useless box without the motor shield. Is my schema correct ? thanks if you read this

grrmisfit (author)2016-04-30

having issues and i think its my switch.. i need an on/off or on/on 3 prong? and not sure where to add debounce in code

BestUsername (author)2016-04-26

Got an arduino board to try this, and after 3 hours of trying to upload code to it, I quit. Wasted a decent amount on cash to try and build this. -.-

About This Instructable

345,886views

1,026favorites

License:

More by riachi:OiO - a desk lamp that has a soul How to control "stuff" from your PCHow to revive an old radio: the easy honest cheat!
Add instructable to: