Introduction: Motion Sensitive Tesla Coil

Picture of Motion Sensitive Tesla Coil

This year I decided to make my garage into a little haunted house. To add some fun and serious scary points, I wrote some code and hooked up one of my Tesla coils to a motion sensor through my Arduino. It now turns on whenever someone walks by, and it's actually very startling.

Step 1: Materials

Picture of Materials
For this, you will need the following things:
  • A Tesla coil - $20 - $50
  • An Arduino - $35
  • A Maxbotix sonar sensor - $25
  • One 12V to 120V relay - Free to $6
  • One transistor and a resistor to match the relay - Free from old electronics (See this Instrucable for more info.)
  • 12V Sealed lead acid battery - Don't you have one already?
  • Various wire
Overall, the total price comes out to about $100, but I had everything except for the sonar sensor.

Step 2: Code

Below is the code for the Halloween part of the program. When someone walks by less than 2m away and no one has passed by for 1.5 minutes, the Tesla Coil will turn on.

int transistor = 13;                                 //transistor base to resistor to pin 13unsigned long time = 0;int avgdistance = 0;void setup(){  Serial.begin(9600);                                //protip: plug in a serial lcd for quick testing  sonarSetup();  pinMode(transistor, OUTPUT);  delay(2000);                                       //give time for everything to get ready  for(int i = 0; i <= 30; i++)                       //get an average distance on how far away the other wall is  {    avgdistance += sonarPulseWidth();  }  avgdistance /= 30;  avgdistance -= 50;}void loop(){  int distance = sonarPulseWidth();  Serial.println(distance);  if(distance < avgdistance && (time + 90000) < millis())    //distance has to be less than the avgdistance away                                                             //and can&apos;t have been triggered in the past 90 seconds  {    digitalWrite(transistor, HIGH);    delay(500);                                      //turn coil on for 1/2 second    digitalWrite(transistor, LOW);    time = millis();  }}

Also, the code to run the sonar sensor is below.

                         //Sonar GND to ground                         //Sonar +5 to +5                         //Sonar TX -- Useless for this project                         //Sonar RX -- Useless for this project                         //Sonar AN -- Useless for this projectint sonarPW    = 5;      //Sonar PW to digital pin 5, 147uS per inch (2.54cm/in)                         //Sonar BW -- Useless for this projectvoid sonarSetup(){  pinMode(sonarPW, INPUT);}int sonarPulseWidth(){  return ((pulseIn(sonarPW, HIGH) / 147) * 2.54);}

You can download the sketch below.

Step 3: Wiring

Picture of Wiring

The wiring is fairly simple for the sonar sensor, just connect PW (pulse width) output to Arduino pin 5, +5V to Arduino +5, and GND to Arduino ground. For information on how to hook up the transistor and relay, see this Instrucable by gandalfsz for more info on how to do that.

Step 4: Testing

Picture of Testing
I was, and still am startled by this thing, and that's while I'm wearing earplugs. Here's me scaring myself silly:

In a few weeks this will go behind a wall of Plexiglas in the soon-to-be haunted house garage.

Comments

austin42 (author)2014-05-15

nice cat

astral_mage (author)2013-09-19

the black cat say its all mines (put in very deep an long purrrrrr here)

Thomas Edison (author)2012-08-02

This is a great project to ste-
I mean, look into. Yeah, look into.

finfan7 (author)2009-10-24

Couldn't you set the coil to always be on as long as it has power and then power it through one of those motion detecting security lights?

robotguy4 (author)2009-10-11

Hmmmm...

Wouldn't the arduino board be shocked?  Perhaps putting it in a Faraday Cage would be a good idea...

DevCoder (author)robotguy42009-10-11

my coil only gives off about 1ft sparks

robotguy4 (author)DevCoder2009-10-12

Ah, so I'm guessing that you put the board more than 1ft away from the coil...  That works!

cool (author)2009-10-05

Nice Kitty! And nice project, a little odd for a haunted house, but cool anyway!

guyfrom7up (author)2009-10-04

pssssttt enter this in the arduino contest

DevCoder (author)guyfrom7up2009-10-04

i have, it's pending approval...

About This Instructable

10,512views

19favorites

License:

Bio: Devin is a cool guy, eh doesnt kill himself while doing stupid things, and doesnt afraid of anything.
More by DevCoder:How to Make a Table-Top Van de Graaff GeneratorHow To Clean a MacbookMotion Sensitive Tesla Coil
Add instructable to: