Tuesday, October 1, 2019

Building the Doomsday Machine from "The Pink Panther Strikes Again" - Part III: Electronics, Arduino, Raspberry Pi

Now it's less than two weeks that our local Community Theater will be performing "The Pink Panther Strikes Again", in which Dreyfus threatens to destroy the world with a Doomsday Machine - which I volunteered to build. My version is made of three parts: A base, a center piece (holding a computer screen, joystick, buttons, and lights), and a "laser gun" at the top. In Parts I and II of this post, I finished the enclosures. Now I address the electronics, and the programming of the Arduino and Raspberry Pi computers.

My other blog posts for this build:
    Doomsday Machine Part I: Wooden Structures
    Doomsday Machine Part II: Finishing the Enclosure

Lights for the Laser Gun

[Mon, Sept. 30]  To achieve a great effect in the play, the Laser Gun has to be very bright. For this purpose, I am using  a 2835 LED Strip. I am using the cold white version (which is brighter than warm white) and the non-waterproof type (easier to solder).


This strip has 120 LEDs per meter, or 60 LEDs per 20" (=50cm), which is the length of the pieces that I will glue to the barrel of the laser gun (six pieces) and to the front rod (one piece).


The wires go through a small hole in the barrel of the gun.

I am really happy that the glue of the LED strip holds really well to the painted cardboard.

The LED strip, glued to the rod at the front is supported by a few cable ties. 

Since I did not have much experience with LED strips, so far, I was a little worried that they might not be bright enough. But, as it turns out, I don't need to worry about this. They are extremely bright.

Lights in the Center Piece

[Tue, Oct 1]  The center piece has ten openings for LEDs. I am using 8mm, 0.5W Straw hat LEDs. The LEDs are glued to two pieces of plywood.


20 Ohm, 1W resistors are directly soldered to the Anodes and connected to each other.

Circuit Board 

[Thu, Oct 3] Now, it's time to approach the circuit board. The circuit is based on an Arduino Pro Mini (ATmega 168, 16kHz, 5V), two shift registers 74HC595, ten transistors 2N2222 (for the 0.5W 8mm LEDs) 7 MOSFET transistors IRLB8721 (for the LED strips), and it is powered by a 12V/48W power supply (those that you buy for LED strips) and a voltage regulator LM7805 (reducing the 12V to 5V for the Arduino and the 8mm LEDs. (I may post more details on the circuit later - either here, or in a separate blog post). 
This is the least rewarding piece of the work. For the enclosure, you can see your progress in every step - the same applies to the programming. But for the assembly of the circuit board, you can only hope that you did not forget any connections, potentially resulting in an extended bug-search. In any case, you should start with a detailed plan for the layout of the circuit on your PCB. 


Then, after 3-4 hours of soldering, it looks like this.



A first quick test of the power and ground lines shows that I forgot a connection of the +5V line to one of the shift registers. This is quickly fixed (and I really hope this was the only bug).  After uploading a little test program to the Arduino, I'm connecting the 12V power supply to test if I can address all the LEDs and LED strips.

[Sat, Oct 5] I connected all the pieces. I soldered wires to the LED Cathodes and to the common Anode,

screwed the LED holder panels into the Center Piece, and connected all the cables to the circuit board (from the LEDs, the push buttons and the joystick). As a little extra-feature and Easter Egg, I also added a piece, that I built earlier as part of my set of Back-to-the-Future props: the Analog Gauges that sit in the glove compartment of the DeLorean.

At this point, I took everything to the theater. Here, I screwed the Laser gun on top of the center piece and connected the cables from the LED strips to the circuit board. 

In the Arduino code, I am using the ShiftPWM library to control the brightness of the individual LEDs and LED strips through the shift registers. I am using this in "high resolution" mode (with 255 levels of brightness) and it works very well. The LED strips have a range from dim to unbelievably bright.

When everything is mounted on top of the base and moved to the stage, it's a really impressive view (but the very bright lights make this very hard to capture).

[Tue, Oct 8] It still took me a while to finish the coding. The Raspberry Pi is set up such that it starts automatically, plays a short start-up video on the screen (featuring a Pink Panther), and then continues to loop another video showing animation of a "SciFi" computer screen (all in green, like those 1970's-80's computer screens). 
The Arduino is reading the push buttons and the joystick and controlling the LEDs, and has five modes of operation: (1) when powered on, there is some low-level activity of all LEDs. (2) a little more activity, when Dr. Fassbender fiddles with the controls, (3) the LED strips are moving slowly from the back to the front, when Dr., Fassbender starts the countdown to destroy the UN building, (4) the same pattern, but faster when Dreyfuss accelerates the countdown, and (5) increasing erratic activity when Dr. Fassbender starts the self-destruct mode.
Here is the final Doomsday Machine on stage.


The following pictures show a quick run-through (the actors not yet wearing costumes), how they start the countdown,


the machine fires,

and the laser reaches the UN building.




Other posts on the Doomsday Machine: