Introduction: Electronic LEGO DL-44 Blaster (Light & Sound)
Update: this project is now available on LEGO Ideas -- so be sure to support it if you'd like to see it sold in stores someday!
Built originally for Star Wars Day 2014, I present to you a project that I've been constantly revising and making additions to since spring 2014 -- into a near-final refined form as you see now. This is a life-size replica of Han Solo's iconic weapon à la Star Wars, recreated with LEGO bricks, and fully rigged to light up and play sound effects with triggered! This particular model -- a prototype with crude electronics -- may seem rough around the edges, and even uses a lot of improvised jury-rigging in its functionality, based on what LEGO pieces and electronics I had available. Building this project was a challenge to say the least, and had more electronic malfunctions than you can shake a stick at! I ran into multiple issues with the Arduino code, the problems with the breadboard parts experiments, wiring the circuit, and of course designing the physical LEGO portion itself. In making this creation, I've taught myself how to program with Arduino, as well as I've improved my electronics savvy so that subsequent electronic LEGO models of mine will be more sophisticated. Consider this project to be an instructional guide for the everyman, with its elaborate functions simplified. Rather than necessarily being a verbatim step-by-step guide, this is more of a chronicle to my experimental prototype, so that you can see my work, make feedback on my design, and even make your own changes if you wish to attempt build this yourself.
In this tutorial, I'll show you exactly how to construct the LEGO frame, where to obtain pieces, how to program the sound/LED functions, how to go about rigging up the electronic components, and finally pointing out some important notes involving the design and engineering. I encourage you to make your own improvements where applicable, as in, if you have any better solutions for engineering and ascetics -- as well as for the electronic functions -- feel free to deviate from my design. Although this is an elaborate build from the LEGO standpoint, for the electronic portion I'm going to illustrate it in very basic beginner terms, so that anyone can replicate the electronics and program the coding with ease.
What you currently see is the Mk. II version of the design. The Mk. I edition of the LEGO DL-44 blaster was built by me throughout April 2014, and used a very crude and inefficient electronics/sound system that was slapped together from hacked Radio Shack parts, and was more or less rushed for Star Wars Day 2014. I didn't promote the project on the internet very much, as I was going to wait until I could retool the project with a custom circuit board and more efficient layout. That being said, this is the second draft of the blaster project, which uses its own custom circuit chip and Arduino programming.
To get things started:
- Like all of my LEGO tutorials, this is not an easy nor cheap project to build for the novice LEGO craftsman.In fact, if you have an intermediate or beginner skill for making LEGO projects, I would not recommend attempting this.
- The electronic portion is rather tricky, but gets easier once you know what you're doing. This of course requires aforementioned soldering savvy. My electronics expertise is intermediate, hence this project was a huge learning experience where I ran into multiple failures and had to troubleshoot constantly to gauge what needs repaired.
- The electronic portion also requires programming with Arduino, which means you must have a functional Arduino unit along with the current software, as well as of course knowledge of how to upload code.
- This project is available for support on LEGO Ideas. This is a prototype of a product I would like to see sold in stores, therefore if/when picked up by LEGO Group via my Ideas entry, a mass-produced model will be streamlined, more movie-accurate, and would contain a small self-contained sound/light box rather than my elaborate electronic hacking. Please keep this in mind, as I'm sure there's bound to be at least one person who'll read this and say, "Why would LEGO release a toy that requires kids to solder and program microchips!!?"
- The LEGO construction of this model is provided with LEGO Digital Designer, a free 3D CAD program from LEGO Group. LDD is very user-friendly and geared towards younger users (e.g. the ages 6-12 demographic), which means a lot of elaborate unorthodox LEGO construction methods often used by adult fans (AFOLs) such as myself are often times disabled -- thus certain spots of the gun's design can exist in real life but aren't reflected in the virtual 3D model. In real life, you can place certain pieces into areas where they're not expected to fit (such as tilting a tile sideways and sliding it in between two parallel LEGO studs), but the simple user interface of LDD disables this. In real life, you can fit a Technic stud inside a LEGO 1x1 cylinder (as in the orange tip of the gun), but LDD has this disabled -- hence in my 3D design, the orange tip of the barrel has most of its pieces unconnected. You'll also see two random rubber tires, which are actually supposed to fit around the circumference of the gun's scope. In reality, you can slide the tires around a 2x2 round brick, but LDD has this disabled too. LDD is also infamous for generating steps out of order at times, so sometimes you'll randomly see steps and pieces appear before they normally would in the physical creation when viewing the building guide mode. You'll see more information on this throughout the tutorial.
Step 1: The LEGO Construction - Background
- Download LEGO Digital Designer from LEGO Group's Website (available in both PC and mac)
- Check my HTML guides for a complete list of parts in their respective steps. At this point, like my previous tutorials I'll make the logical assumption you're a skilled LEGO builder who's able to seek/purchase parts from various sources online such as eBay or Bricklink.com, or in real life from LEGO Stores. This particular project contains about 400 LEGO pieces (if followed properly) -- many of which are standard pieces available in a lot of recent sets, whilst some pieces are rare and must be obtained online. I know for a fact that a few select pieces are difficult to obtain, so feel free to make changes where necessary.
- This tutorial contains each section of the gun separated into a modular form in three LDD files, zipped (refer to each download link for the sections): this is because the electronic parts must be added before the project is fully construction and "sealed off". For instance, the LED and wires for the barrel have to be attached before attaching the barrel to the chamber, whilst the internal wires have to be soldered while the sides/top of the chamber are removed. The batteries are crammed into the handle of the gun, whilst the speaker and sound board are housed in the box up front where the gun's magazine would otherwise go. The handle can have its face removed so that batteries can be easily replaced without tearing the whole thing apart, and the sides of the gun can be also easily removed for making repairs. The gun's chamber, trigger, hammer, and handle should be all built first and assembled -- the barrel, the side panels, and the scope should all be build last, and assembled in conjunction with the electronic parts where applicable. In other words, my 3D tutorial doesn't show the completed virtual gun in a solid form -- it has each of its major components separated, as they're intended to be built one portion at a time and subsequently assembled -- not as in one gun being wholly constructed from bottom-to-top one piece at a time like a linear LEGO model.
What you'll essentially be doing is building each segment of the gun individually, inserting the electronic parts where needed, then sealing the whole thing up. Naturally of course with the magic of LEGO bricks, you can always remove/dismantle certain parts of the gun to make any repairs with electronics or to swap out the batteries, and you can even make substitute color swaps like a bright orange gun instead of black. Also, since this is a prototype design, it has its flaws, and isn't recommended to be used a legitimate toy gun; most likely if you run around with it in your backyard or take it with you to a 501st Legion parade, some of the pieces could fall off -- hence this is more of a permanent display model, like those expensive Force FX Lightsabers versus the cheap "expandable sword" Lighsaber toys you see at Walmart! If/when this ever becomes a real marketed LEGO toy via Ideas, it'll most likely be a master-build, and something you'd want to keep on a pedestal or in a case out of harm's way.
Step 2: LEGO Portion: the Gun's Main Frame
Please refer to my HTML 3D guide for a list of parts (found on the last step of the HTML page). In this section you'll see the gun's chamber, firing mechanism, magazine, and handle: in the LDD file, follow the steps from the beginning, and when the gun's frame and handle are built, attach the handle to the rear of the gun. The handle of the gun serves as the housing for the battery, which uses wires channeled across the gun's trigger guard into the magazine. Within the magazine will eventually be the speaker and sound chip -- hence in this portion, the gun's sides, roof, barrel, and scope are missing -- as they'll be eventually attached to seal off the whole project.
The firing mechanism uses a small system of miniature Technic axles, pulleys, and rubber bands to make the firing pin spring forth and reciprocate when the trigger is pulled; the firing pin slides across a smooth panel of tiles. As the firing pin slides down a track, it'll strike a momentary pushbutton to be later attached. When the firing pin makes contact with the button, it will eventually control the circuit's function to launch the LED/sound code. Although LEGO group does in fact manufacture tiny rubber bands for certain projects, I had a hard time trying to find proper sizes, in order to maintain more authentic LEGO pieces. Alas, I purchased a cheap pack of black rubber bands for ponytails at Rite Aid for about $2 USD. These little rubber bands (smaller than a newspaper rubber band, but larger than the ones for braces) will be attached to the gun's firing mechanism as shown in the photos. When the trigger is pulled back, the rubber bands stretch and spring the firing pin forward, and subsequently go back to start.
Please note: the handle is somewhat difficult to attach, and in fact LDD doesn't allow it attached in its current form (which is why it's not attached to the frame in the 3D guide). The handle is tilted at an angle and held on to the frame via a few Technic pins placed in the proper spot. I can't really explain exactly how these go inside, aside from that you have to tilt the handle, line up the Technic holes, and insert the pins where applicable.
Also note: there's a random black disk floating on the ground. In my real life model, I can successfully fit 12 Technic disks around the axle to form the front grille, but LDD for some reason says only 11 disks fit. Naturally this part is included in the file, but when you actually build it, add the 12th disk to the front grille.
Step 3: LEGO Portion: the Roof and Sides
Refer to the file which contains the 3D guide for the gun's roof and side panels, and check the parts list above for what you'll need. Once completed, DO NOT attach the sides and roof to the gun yet -- until later on when the electronics are inserted. Although the side panels can be easily removed, the roof is tricky to remove once attached, and when you try to pull it off, it can damage the firing mechanism. I'd personally however recommend attaching the gun's starboard side (your side right) first, so that the electronics can rest up against the wall of the magazine (refer to the attached photo to see what I'm talking about). The gun's port side (your left) wall doesn't cover up as much as the starboard, which as you can tell in the final photos, the wires can be seen. This was done as a last minute idea, because the final gun had to be reduced to 3 volts DC instead of 5, which impacted the sound output -- so to deal with this, I left an opening by the front grille so that more sound can escape. If the exposed wires are an issue for you, I'd either recommend using black wires to blend in with the frame, or to slightly adjust the port side wall to go to the edge of the front grille.
Step 4: The LEGO Portion: Barrel and Scope
The final part of the LEGO portion involves making the gun's barrel and scope, which both appear to be broken up in the 3D designer. This is because LDD doesn't allow unorthodox building techniques, hence although in real life, a Technic pin can go inside a cone piece, the software doesn't allow this for some reason. That being said, please refer to the photos of the barrel and scope to see how to correctly place the parts, such as the barrel's orange tip and the scope's washer rings (made from black rubber tires wrapped around the round bricks).
Inside the barrel is a hollow Technic tube, which shall have the LED's wires snaked through it, and ultimately weaved into the gun's magazine, via the the gun's action. For now, just ensure the barrel is hollow, and that the orange cap stays on securely.
Step 5: Electronics: Overview
The electronics portion of the guide is rather tricky and frustrating, but to make things easy, I'll present it in layman's terms where applicable and word it in such way that an amateur can easily program/build it with simple easy-to-find pieces. The Mk. I design of the gun used an incredibly crude electronics portion: I purchased a cheap Radio Shack sound record/playback module, slightly modified it, then rigged it into a parallel circuit with a homemade 555 IC "one shot" LED blinker. In other words, when pulsing a pushbutton, the sound module would play a sound effect of the blaster pistol, in addition to making a single LED flash on for one second. The whole thing was powered by a 9V battery, and due to my then miniscule electronics savvy, I was unable to have the project power down -- thus the battery died after a few days. I've since then greatly improved my electronic abilities and began coding with Arduino, and as of now -- after numerous experiments -- I've developed a tiny barebones audio circuit for playing small sound clips off of a single chip. The overall premise of this barebones sound player is just the barebones Arduino, which has only the basic elements of the aforementioned circuit, such as the ATmega32 chip, the voltage regulator, few resistors, capacitors, and oscillating crystal. This circuit has some additions like terminal sockets for connecting the batteries and speakers, and also a small area with a transistor for amplifying the speaker. I programmed this chip using a tutorial I found online called "Arduino as an ISP", which uses the actual Arduino's function to upload code on standalone chips on a separate breadboard. Then once the chip was programmed, I placed it into my barbones Arduino on a breadboard circuit, and with some minor tweaks I succeeded in blasting the sound with pushbutton pulses!
This is an evolutionary design I've been working on for quite some time, mostly through trial and error, as well as countless failed experiments with physical electronics in addition to the code itself. The function of the code is to keep the chip in a power down mode by default to save battery life, and when pulsed with a momentary pushbutton, the LED blinks for about 1 second as a small audio clip plays. The blinking LED is a slightly modified form of the preexisting Arduino LED blink code that comes standard, the sound blast is a modified version ofthis particular code for playing PCM wav clips, and the sleep mode was modified from this tutorial I found. Most of what you see in this circuit I've made was strictly by trial and error and messing around with delay and loop functions in my code. For instance, I'd follow various tutorials verbatim, but would have failed results such as the sound output being quiet/muffled, the LED not blinking, or the transistor heating up. With many countless hours experimenting with various component parts and discovering how they work, I've succeeded in programming a standalone chip with the functional code, and developed a small sound player with adequate sound output. Although this circuit works perfectly fine for me and contains no errors in my various tests, If you're an electronics expert and you've noticed some issues with the layout and/or some parts which should be adjusted, feel free to point them out. For example, I'm using a 2N2222 transistor to output the sound in conjunction with a few resistors; although the sound plays just fine and the parts don't heat up, you might say to yourself, "Baron, you probably ought to replace the transistor with model# XXXXXX and use a resistor with fewer Ohms for cleaner sound!" or perhaps you might notice an error in my code. Again, although both the code and circuits function properly as intended, I'm not an expert, so if YOU are an expert, I encourage you to make suggestions and corrections where applicable -- that's what the comments section is for!
Please note: some of the blaster photos are inconsistent with the electronics parts I've assembled. Long story short, my breadboard circuit and first draft soldered chip were made when I assumed I could fit four AAA batteries for 5 volts to power my project -- hence I included the voltage regulator and 10uF capacitors to step the power down from 6 to 5 volts, and I included a transistor in series with resistors to make clear sound. After I soldered the whole chip based on my breadboard design, I learned that I could only fit two AAA batteries, so I had to remove the voltage regulators from the design, but at that point I still had the transistors and resistors soldered in. My final circuit is almost verbatim to the barbones "Arduino on a Breadboard" circuit from the link above, with the voltage regulator omitted -- but still retaining the 16 MHz oscillator, microcontroller, et alia.
Step 6: Programming the Chip
There are numerous tutorials online of how to upload code from the Arduino to a standalone chip on a breadboard (such as ATtiny85, or in this case ATmega32), but alas, I've had nothing but failed results when using them personally -- until I found this particular guide from Boris Landoni (most of the images in this section are taken directly from his tutorial). In his tutorial, he explains how to use a handful of parts to easily transfer code from the Arduino to a chip on breadboard, by first slightly adjusting the Arduino software. Thus, you can utilize the entire chip's space without the need of burning a bootloader on the standalone chip.
For this portion, I used the following items:
- Arduino IDE software -- free download.
- Arduino Uno: this is the unit I currently use, which is successful in uploading sketches to the chip. I personally don't know about other models like the Mega, but based on my assumption, they should work as well. Boris' tutorial states that the Duemilanove works fine.
- Breadboard (any size).
- Colored jumper wires - you can buy a kit of these from Radio Shack for less than $10 USD, I believe. I used standard jumper wires, but Boris' tutorial uses male jumper leads.
- ATmega32P-PU chip to program. These generally retail online from various sources from about $3.50-4 USD, available from Sparkfun, Digikey, Jameco, Mouser, Newark, et alia. I bought four of them from an eBay store called Atoms Industries. It's imperative that you purchase this specific model! The ATmega32P-PU is the latest chip and the one that works with this tutorial.
- 16 MHz oscillating crystal - these are unfortunately difficult to find at stores, but online you can get several for real cheap.
- Two 22pF ceramic capacitors - Radio Shacks don't tend to sell these obscure sizes, so I bought a ton off eBay.
- One 10uF electrolytic capacitor - usually around $1.50 at Radio Shack.
- One 10K Ω resistor.
One 220 or 470 Ω resistor (optional). This is for the LED that blinks on the breadboard when the sketch has been uploaded.
- One 5mm LED (optional). When the sketch successfully uploads onto the board, this light should blink.
Assuming you're not familiar with programming microcontrollers via an Arduino, for the sake of brevity, please refer to Boris' link up above, which breaks down the necessary steps of where to place the wires and how to modify your code in greater detail. I'll sum things up and give you the basic rundown:
- Select "Arduino as an ISP" from the examples menu, select your model Arduino from the boards menu (in my case Uno), the upload sketch. Your Arduino is now configured to act a programmer for individual microctrollers.
- Set up your breadboard according to the photos, with the proper items in their exact locations -- this includes the capacitors, resistors, 16 MHz crystal, wires, ATmega32, and the Arduino itself (the Arduino connected via USB).
- Locate your "boards.txt" file, found in: C:\Program Files\Arduino\hardware\arduino (that's where mine is located -- yours could vary based on where you installed the Arduino IDE).
- In your boards.txt file, copy and paste the text from my attached notepad file into the bottom of the preexisting lines of code.
- Once you've done this, restart the Arduino IDE, look to the tools menu, select boards, and at the bottom you should see a new board called "ATmega in Stand Alone - Julius Rocks! (Arduino as ISP)" -- I obviously put that there as a flag to know if it worked! Select that board.
- Open up the DL-44 blaster code from the attachments and view it in Arduino IDE. My code contains a small sound clip of Han Solo's blaster firing; the sound byte was extracted by me from the exact scene where he shoots Greedo (first) for movie accuracy! I've converted the sound clip into binary code, as seen in the source code information. Also, I have specific delays in the code to make the front muzzle flash blink rapidly for one second; you can mess with the delay function to speed/slow this up, or remove the blink.
- Select "Upload Using Programmer" -- and NOT via regular upload.
- If it worked, the code will go to your chip in a matter of seconds.
- Remove your ATmega32 from the breadboard, and move on to the "Arduino on a Breadboard" step to test!
Photo credits: Boris Landoni.
Step 7: Arduino on a Breadboard
If you've succeeded in uploading the sketch, now it's time to place the programmed ATmega32 chip on a breadboard to test it out! This section no longer requires your Arduino, so go ahead and unplug it.
Parts needed -- most of these can be purchased at Radio Shack for a few dollars U.S., and of course most of these you can re-use from the prior step for programming the chip. The resistors, capacitors, LEDs, and transistors were each in assorted multi-packs I bought at Radio Shack that had various sized components together. I think I paid like $10 for several hundred various-sized resistors, from 1 Ω to 2 million Ω! Here's a cool online tool for understanding resistor colors.
- Breadboard (you can keep your chip on the breadboard from the last test and re-arrange the parts -- I have two separate breadboards I use, so it's up to you).
- Colored jumper wires: use the same ones as before.
- LEDs: originally I used a tiny red 3mm LED for the pin 13 indicator, and a super bright white straw hat LED for the gun's muzzle flash -- but as you'll read about at the bottom of this list, I made a last minute revision with the power source, hence I opted for a smaller LED for the gun's barrel. The small indicator LED for pin 13 (pin 19 on the ATmega32) is there to blink whenever the circuit is pulsing from trigger pulls -- it should be off when the Arduino code tells it to go to sleep.
- Your newly-programmed ATmega32P-PU chip from the previous step.
- 16 MHz oscillating crystal.
- Two 22pF ceramic capacitors.
- Two 10K Ω resistors.
- One 100 Ω resistor.
- One 10 Ω resistor.
- Two 220 Ω resistors.
- Momentary pushbutton -- NOT an on/off toggle switch.
- One 8 Ω .1 Watt speaker. I got mine at Radio Shack for $4 U.S., and I've seen similar ones online (of slightly different values) for $2-5 a piece. It's crucial to keep your sizes within the same confines, and adjust resistor value where applicable.
- 2N2222 transistor: these are available at Radio Shack individually or in packs of several.
- Two AAA batteries and a small housing for them.
Refer to the illustration for correct placements of the component parts. Rather than providing a schematic, since this is a project I'm intending to present to amateurs, I designed an illustration instead. Please note: this breadboard illustration you see evolved from an early design in which I intended to use 5 volts DC in the Blaster, which meant the schematic required a voltage regulator and capacitors. Also, the placement of the resistors in conjunction with the transistor was done when my first breadboard circuit required 5 volts. After I soldered the chip and realized I couldn't fit four AAA batteries into the gun like I planned to, I had to remove two and have the gun powered by 2 AAAs, thus removing the voltage regulator -- but at that point, the resistors and transistors had already been soldered. That being said, the 3 volt version (in this tutorial) has slightly duller light and sound, as a result of having less power and more resistance than intended. I did however eventually try to experiment with having 3 AAAs, and the sound/LEDs were more powerful -- so in later revisions I might re-tool the LEGO portion of the gun to fit 3 AAA batteries for 4.5 volts. Feel free to experiment with various resistor and transistor configurations in your breadboard, and make sure nothing heats up!
What you see in the illustration is a simplified and modified version of the "Arduino on a Breadboard" circuit, which is a method to build a barebones Arduino module -- or in my case, utilizing the necessary parts from Arduino Uno (the microcontroller, the oscillating crystal, and capacitors) to have a small, portable chip with my audio and LED code uploaded onto it. In the aforementioned link, the breadboard requires a voltage regulator, as it's intended to be powered by 5 volts DC. Again, that was my original intention, but at the last minute when I assembled the gun, I couldn't fit enough batteries and thus removed the regulator. My current blaster uses 2 AAA batteries, and only gets 3 volts. The sound output and LED brightness are noticeably duller versus my original breadboard made according to the link above. My illustration was based off the Arduino on a Breadboard tutorial, only in my current illustration I have the voltage regulator and the two 10uF capacitors removed. The two 22pF capacitors, the 16 MHz crystal, the ATMega32, and reset/switch resistors are absolutely vital for the barbones Arduino. The transistor by the speaker is there to increase the sound output, but please note that the resistor configuration in the diagram was made when I used 5 volts. Using the same configuration with 3 volts makes the sound not as loud as I intended, but alas, I already soldered the circuit with the resistors and transistors prior to stepping it down to 3 volts. Again, before you solder your board, you can experiment with different resistor and transistor values.
After you've experimented successfully with the breadboard, you can move on to soldering each component into a circuit board!
Arduino/ATmega32 pinout diagram courtesy of Arduino Playground.
Step 8: Building the Circuit Board
This phase was one of the most difficult and tedious sections, and I ran into numerous errors that delayed the release of this project. The soldering for this is easy for the intermediate or professional electronics guy, but if you're just a beginner, you'll probably run into obstacles. I'd highly recommend reading this Instructable regarding soldering methods if you're a beginner. This circuit will essentially just be everything you constructed on your breadboard -- only now compacted into a tiny little circuit board, but nonetheless following the exact same layout.
Here are the final parts required. Most can be re-used from the breadboard you just finished building, but a few new things must be purchased, such as wires.
- Mini circuit board; any size greater than 2 inches square will do, but the key is to ensure the ATmega fits across it. When all of the parts are soldered down, you can trim off the excess area of the board to fit inside the pistol's magazine.
- 30 gauge wrapping wire for the barrel's LED.
- 24-26 gauge wire for the trigger switch.
- Two options: female header pins or terminal screw blocks. I used both in my original circuit, but unfortunately the particular terminal block I soldered to the board was defective, which caused the battery wires to frequently come loose. At the last minute I had to create a jumper of two female header pins to keep the battery wires in place, but the terminal block was soldered down pretty sturdy -- hence in later photos you'll notice the green terminal block on my circuit, but with no wires going inside it.
- Also optional: IC socket for 28-pin microcontrollers. I have several of them, but the connection was too tight and was bending the legs of my ATmega when I'd try to insert it, so instead I made two rows of female header pins.
First begin by soldering the 28-pin DIP socket (or two rows of female header pins) into the circuit board. Never add the actual ATmega until the whole shebang is soldered, for safety purposes! Following your breadboard that you've constructed based on the previous steps, place the necessary components into their respective areas -- the resistors, capacitors, header pins, and oscillating crystal. Refer to the diagram to see the pinout for the ATmega: in your breadboard, you should have successfully had your components attached to the proper pins on the ATmega for functionality. For example, the indicator LED should be connected to pin 19 of the ATmega, the socket for the barrel's LED wires to pin 18, and the audio output connected to pin 17. The audio output will then go to an empty area on the board (preferably out of harm's way from other connections), connected to a 100 Ohm resistor, and to the base of the transistor. The transistor's emitter will go to the header pins for the speaker, and finally to the positive rail (make sure the connection of the speaker's header pins doesn't have the bottoms touch, or you'll create a short circuit). Also, the speaker is polarized: the red wire goes to the pin touching the emitter, and the black wire will go to the pin touching the positive rail. The collector is connected to a 10 Ohm resistor, then to the ground rail. The positive rail should lead to a specific pin slot (or terminal slot), and the ground rail should lead to its respective slot -- the two rails must remain separated. There are two 10K Ohm resistors for ATmega pins 1 and 4: the first is to prevent the chip from resetting, and the second one is to ensure your trigger switch doesn't get stuck on a permanent loop. First start by having the right pin of your female header pins connected to pin 4 of the ATmega, connect 10k Ohm resistor to the right leg, then to the positive rail. The left leg of the header pin will then go to the ground rail. These header pins will keep your trigger's pushbutton connected.
Again, follow your breadboard circuit to get the proper placements of the final soldered components, but make sure to cram them together carefully to utilize as much space as possible. Internal space is limited inside the blaster's magazine, which means any excess circuit board must be cut off with wire cutters, a knife, or scissors! As you can see in my attached photos, I trimmed around the circuit board to remove non-used holes. Underneath the board is an ultra-compact mess of jumper connections!
Arduino/ATmega32 pinout diagram courtesy of Arduino Playground.
Step 9: Assembling Each LEGO Module and Wiring the Electronics
- Barrel muzzle flash LED: cut 10 inches of 30 gauge wrap wire. Trim the pins of LED to be much shorter, but ensure the anode and cathode aren't mixed up. I marked the cathode's wrap wire (negative/ground) with a black marker. Solder the wrap wire to the pins of the LED, then snake the wires through the barrel and weave it into the gun's magazine (refer to the photos where the blue 30 gauge wire goes through the gun), but don't attach the gun's barrel to the gun just yet. Then enclose the front of the barrel with the transparent orange tip. The LED's wrap wire is thin enough to travel through the hollow tube of the barrel, but it's imperative that no exposed wires touch, or else you'll get a short circuit!
- Trigger pushbutton switch: cut 9 inches of 24-26 gauge wire, solder to the pins of the pushbutton. My button wasn't polarized, and the wires didn't matter. Place the switch on the slot at the end of the gun's firing pin track. Once the switch is in place, attach the barrel to the front of the gun, then place the gun's roof on top. This should keep the trigger switch in place. Use a pair of small needlenose pliers to guide the barrel's wires and the switch's wires through the small infrastructure into the gun's magazine.
- Attach the gun's starboard (right) side -- the side with the three grey circles.
- Place a piece of electrical tape behind the speaker as just a safety precaution, so its magnet doesn't interfere with the connection. Then insert the speaker into the header pins of your soldered circuit chip.
- Place the battery back in the gun's handle (with the batteries removed). Then snake the two wires through the gun's trigger guard, which is a hollow ribbed tube. Push the wires through the tube and into the magazine.
- Bundle up the circuit board and speaker, then starting with the speaker facing the front grille of the gun, carefully place the chip inside at an angle so that it fits snug, and you have easy access to the header pins and/or terminal blocks.
- Insert the battery connectors to their respective pins, ensuring you have proper polarity. Do likewise with the blue wrap wire from the barrel's LED, and the two wires from the trigger. This wire connection step is rather messy and frustrating, and in my version, my header pins were cheap and kept making the wires loose from any slight jolts. If your circuit works fine, you can always hot glue the pins in place. I opted to have mine with the ability to be removed in case of repairs, but in doing so I risk having them come loose when there's too much shock on the gun.
- The mess of wires and parts should fit snug into the gun's magazine. Then attach the gun's port (left) side, the side with one grey circle.
- Place two AAA batteries into the case.
- Pull the trigger and see what happens.
- Shoot Greedo first!
I pity the fool who thinks Han shot second.
Step 10: Troubleshooting & Design Notes
Most likely despite your best efforts, you're bound to run into some trouble (like I did, to say the least)!
- Ensure that any exposed wires do not touch (especially LEDs), as this will create a short circuit.
- Always adhere to proper polarity: + to positive, - to ground.
- If you deviate from my breadboard, be sure your power supply doesn't exceed 5 volts DC. If you try to use more power, you must use a voltage regulator with capacitors in series (refer to the Arduino on a Breadboard tutorial again for this).
- An oscillating crystal is an individual unit, and its rating cannot be adjusted. In other words, you can combine two 100 Ohm resistors in a series to get 200 Ohms, but placing two 8 MHz crystals in a series will not give you 16 MHz. Keep this in mind when purchasing parts.
- As mentioned in the introduction, this model is not intended to be played around with like a regular toy gun -- rather it's more of an elaborate trophy model to keep on your shelf and show off to your friends, and not to carry around in public or for use with cosplay. This prototype design is way too fragile for rough usage -- but hopefully in subsequent revisions or if it becomes marketed as a real LEGO Star Wars toy, it would be much more durable, movie-accurate, and have its electronics more sophisticated.
- If you'd like, go ahead and use my breadboard design to make your own circuit board via Autodesk 123D or OSH Park -- in fact, after completion of the Mk. I Blaster, that was my intention, to get a custom circuit board printed, but due to time restrictions, I had solder my own blank board. In future electronic LEGO projects, I'll most definitely get a small custom circuit board printed to save the hassle of troubleshooting errors and damaging parts from incorrect soldering.
- You're absolutely free to deviate and make improvements. If you'd like to make a non-electronic version for whatever reason, you can do so so by omitting the electronics steps and neutering the firing mechanism. You can make this design any color you'd like, aside from the current black, grey, and brown scheme. Personally, I was actually considering building multiple copies of this: a second gun white and orange, and a third one orange and black, to resemble the 1990s Star Wars Laser Tag set that used like 16 AA batteries! Remember that?
Step 11: Credits and Acknowledgements
Thanks again to everyone who's helped support my LEGO projects over the years! With your feedback and encouragement, I can keep making these nifty creations to dazzle the likes of you, and due to popular demand I'm going to publish more and more Instructables tutorials. I'd like to thank the folks fromArduino Playground for providing their sample codes -- such as LED blinks, PCM sound players, and sleep modes -- so that I could combine the codes and experiment until perfection.
-Baron von Brunk
All photos taken by Julius von Brunk, unless specified. Links to the source images can be found in their respective steps.
LEGO® is a trademark of the LEGO Group
Star Wars, Han Solo, and Greedo are property of 20th Century Fox Lucasfilm