Introduction: Capacitive Touch Vibrating Box

One day I came into a cell phone vibration motor. After wondering what to do with it, I came up with this. If you have ever seen those rattlesnake egg pranks that "rattles" when you open it, this is a lot  like it... only with arduino. So it's better!

Step 1: Parts

- Small box
- Arduino ( Radio shack )
- Arduino Motor Shield 
- Standoff ( something so the motor.....
- Vibration Motor ( Radio shack )
- Resistor 3.3 Ohm (Radio shack )
- Electrical tape
- Aluminum tape/foil ( Aluminum tape is better )
- Hot glue gun
- Soldering iron
- Solder
- Scissors 
     If you want to make a DIY vibration motor you will need
     - 6v hobby motor ( Radio shack )
     - Hot glue gun
     - A small weight ( A fishing sinker works well )




Step 2: DIY Vibration Motor

If you bought one, skip this step, if not, keep reading,
solder a wire to each lead of the motor, then hot glue your weight to the shaft.

Step 3: The Motor Shield

Read this instructable on the motor shield by randofo
https://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/

Step 4: The Capacitive Censor

Go to the arduino website, read up and download the capacitive touch library, then go to the next step
http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense#.Uz4qfNxhWKw


If your not sure how to make one don't worry, i'll show you in a later step.

Step 5: Put It All Together

Use hot glue to mount the motor to the inside of the box to where  you can still shut the box. Next tape the aluminum tape to the lid of the box, solder a wire to one side of the resistor, then twist one corner of the foil around the stripped end of the wire and tape in down ( conductive glue works great for this ). Connect the motor to the motor shield and use hot glue to mount the arduino and the motor shield, plug the wire side of the resistor into pin 4, and the other side into pin 5.

Cover the resistor and any exposed leads with electrical tape.

Step 6: The Code

copy, paste, and upload the code, then wrap a 9volt battery in electrical tape and plug it in.

#include <CapacitiveSensor.h>

/*
* CapitiveSense Library Demo Sketch
* Paul Badger 2008
* Uses a high value resistor e.g. 10 megohm between send pin and receive pin
* Resistor effects sensitivity, experiment with values, 50 kilohm - 50 megohm. Larger resistor values yield larger sensor values.
* Receive pin is the sensor pin - try different amounts of foil/metal on this pin
* Best results are obtained if sensor foil and wire is covered with an insulator such as paper or plastic sheet
*/


//CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);        // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil
CapacitiveSensor   cs_4_5 = CapacitiveSensor(4,5);        // 10 megohm resistor between pins 4 & 6, pin 6 is sensor pin, add wire, foil
//CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,8);        // 10 megohm resistor between pins 4 & 8, pin 8 is sensor pin, add wire, foil

//int stereo = 13; ignore this



void setup()                   
{

  pinMode(12, OUTPUT);
  pinMode(9, OUTPUT);


   cs_4_5.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
   Serial.begin(9600);

}

void loop()                   
{





    long start = millis();
//    long total1 =  cs_4_2.capacitiveSensor(30);
    long total2 =  cs_4_5.capacitiveSensor(30);
//    long total3 =  cs_4_8.capacitiveSensor(30);


/* if( total2 > 10000)*/ 
   if( total2 > 370){ digitalWrite(12, HIGH);
                           digitalWrite(9, LOW);
                           analogWrite(3, 255);}
                       if ( total2 < 350){     digitalWrite(9, HIGH);}

    Serial.print(millis() - start);        // check on performance in milliseconds
    Serial.print("\t");                    // tab character for debug windown spacing

//    Serial.print(total1);                  // print sensor output 1
//  Serial.print("\t");
    Serial.println(total2);                  // print sensor output 2
//    Serial.print("\t");
//    Serial.println(total3);                // print sensor output 3

    delay(100);                             // arbitrary delay to limit data to serial port
}

Step 7:

The sensor may be touchy. Try playing with the threshold to get the desired result.


Your done! Plug in the battery, close the lid, set aside somewhere and wait for an unsuspecting victim to come upon this strange new site. Maybe write "DO NOT OPEN" on it.


Arduino Contest

Participated in the
Arduino Contest

Full Spectrum Laser Contest

Participated in the
Full Spectrum Laser Contest