Motion Sensitive Tesla Coil




About: Devin is a cool guy, eh doesnt kill himself while doing stupid things, and doesnt afraid of anything.

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

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&apost 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

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

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.



    • Tape Contest

      Tape Contest
    • Jewelry Challenge

      Jewelry Challenge
    • Trash to Treasure

      Trash to Treasure

    10 Discussions


    5 years ago on Introduction

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


    9 years ago on Introduction

    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?


    9 years ago on Introduction


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

    2 replies

    Reply 9 years ago on Introduction

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


    9 years ago on Introduction

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