Friday, December 19, 2014

Thermal Detonator

So I've been thinking about making something using an Arduino and the 3d printer.  Over on Thingiverse, I found the inspiration, thanks to member AprilStorm and the excellent Thermal Detonator model.  If you're a Star Wars fan, and even if you're not, you probably know about Princess Leia's little shenanigan in Jabba's Palace.  So it goes without saying, a Thermal Detonator can be helpful when it comes to those overly tedious negotiations.

I printed the whole thing on one build plate with support.  I removed the support from the tiny openings on the detonator before printing..  I think I set it to a .2 mm layer, 3 shells, and 30 % infill.
I'm currently using a Flashforge Creator.  For the models I'm using a very nice software package called Simplify3d.  It took a surprisingly long time to print but looked great and the pieces fit well together without any modification.


So on to the lights.  I didn't just want this to light up and be static.  I wanted this thing to have some life, and a cool flashy effect like in the movie.  I learned that Adafruit produces a much smaller and less expensive micro controller they call the Trinket.  I ordered two of them just in case I wanted to build another, cause they're just so cheap.  I also got a nice little battery compartment and two of the button style batteries, I think they're CR2032 or something close to that.  Either way it provided just over 5v which is what I needed to power the Trinket and a few LEDs.

I did a nasty job of wiring the whole thing up but it was sturdy, and compact.  I soldered 3 yellow LEDs to pins 0, 2, and 3, then a larger red LED to pin 1.   To each LED circuit I added a small resistor in the positive side between the bulb and the board.  If you're making one of these, be sure to have some heat shrink tubing for these tiny little wires and connections to keep it all from shorting out once its time to cram it all in the enclosure.

For the Trinket I uploaded a modified version of a Christmas Tree sketch I found in a forum.  I wanted to give the author credit but I haven't been able to locate the forum again.  I believe I only changed a few things like the pin numbers and the number of lights.  It works great for this project.

Just a quick note: Below is an updated sketch reworked by James Tucker.  This has been tested and seems to work great.  Enjoy.

//Thermal detonator

#define NR_OF_LIGHTS 4

int blink_delay = 400; //millisec
int blink_count_delay = 1000; //1 second




/**
*
*/
void setup() {
    //not sure if we need to do anything here
  //randomSeed(analogRead(0));
  //for (int i = 0; i < NR_OF_LIGHTS; i++) {
  //  values[i] = (int)random(230) + 13; // start values between 'max min' and 'min max'
  //  steps[i] = (int)random(4) + 1; // steps between 1 and 4
  //}
}

/**
*
*/
void loop() {
  //decrementing the main light by 32 every time to make it slowly dim
  //during the timer (main light is pin 1
  int count = 0;

  //have 4 lights, they are not plugged in binary order, so the
  //order of stuff is a little different
  //light 0 = middle position
  //light 1 = top
  //light 2 = last position
  //light 3 = first position

  //analogwrite(pin, value 255 - on 0 - off);
  //write out a 7 - 111
  analogWrite(0, 255);
  analogWrite(1, 255);
  analogWrite(2, 255);
  analogWrite(3, 255);
  delay(blink_count_delay);

  //write out a 6 - 110
  analogWrite(3, 255);
  analogWrite(1, 223);
  analogWrite(0, 255);
  analogWrite(2, 0);
  delay(blink_count_delay);

  //write out a 5 - 101
  analogWrite(3, 255);
  analogWrite(1, 191);
  analogWrite(0, 0);
  analogWrite(2, 255);
  delay(blink_count_delay);

  //write out a 4 - 100
  analogWrite(3, 255);
  analogWrite(1, 159);
  analogWrite(0, 0);
  analogWrite(2, 0);
  delay(blink_count_delay);

  //write out a 3 - 011
  analogWrite(3, 0);
  analogWrite(1, 127);
  analogWrite(0, 255);
  analogWrite(2, 255);
  delay(blink_count_delay);

  //write out a 2 - 010
  analogWrite(3, 0);
  analogWrite(1, 95);
  analogWrite(0, 255);
  analogWrite(2, 0);
  delay(blink_count_delay);

  //write out a 1 - 001
  analogWrite(3, 0);
  analogWrite(1, 63);
  analogWrite(0, 0);
  analogWrite(2, 255);
  delay(blink_count_delay);

  //write out a 0 - 000
  analogWrite(0, 0);
  analogWrite(1, 0);
  analogWrite(2, 0);
  analogWrite(3, 0);
  delay(blink_count_delay);

  //blink all lights for 2 seconds
  analogWrite(0, 255);
  analogWrite(1, 255);
  analogWrite(2, 255);
  analogWrite(3, 255);
  delay(blink_count_delay);
  delay(blink_count_delay);

  //random for a 100 iterations, increment after every loop evaluation
  while(count++ < 100) {
    for (int i = 0; i < NR_OF_LIGHTS; i++) {
      //pick a random light value
      int value = (int)random(255);

      //pick a random on/off
      int on = (int)random(2);

      //if we have a value, display the value, else turn the light off
      if (on > 0) {
        analogWrite(i, value);
      } else {
        analogWrite(i, 0);
      }
    }
    delay(blink_delay);
  }

}




After getting the lights working I haphazardly painted the outside
with whatever I had on hand.  I used some spray paint and a product
called rub-n-buff to get a metallic look.  






I had at first wanted to make the top piece that slides be the switch, but in the end added a simple lighted push button to the back side, which I think actually added to the look.  I believe I wired the LED in the button to pin 1 same as the large red light in the front.

I gave this one away to my friend James Tucker.  I found a few explosive warning labels and printed those out for the box.  Merry Christmas James!







No comments:

Post a Comment