Introduction: Electronic LEGO Super Mario Bros. Mushrooms

About: This is the official Instructables profile of Baron Julius Alexander von Brunk, an eccentric multimedia artist in New York City! Baron von Brunk is widely known as a master LEGO craftsman whose work has been p…

Submitted for the approval of the Instructables society, I bring to you another electronic LEGO project with a retro video game theme!

Using the exact same principles for design and engineering as my Electronic Super Mario Starmen, I've built another series of small musical LED sprite pieces. These ones are roughly the same exact size of their predecessors, contain the exact same electronics (the circuit, the batteries, LEDs, speakers, and Arduino code), and are assembled in the same fashion -- only instead of invincibility stars, I've got four different mushrooms with multiple audio options!

The tutorial for these mushrooms will be identical for all four, but here are the color choices:

  1. Green head with white dots: 1-up from the 16-bit era
  2. White head with green dots: 1-up from Super Mario Bros. 3 (same thing as above, only with its base colors swapped)
  3. Red head with white dots: power mushroom from 16-bit era
  4. White head with red dots: power mushroom from Super Mario Bros. 3 (same thing as above, only with its base colors swapped)

For both of the green mushrooms, I've used an Arduino melody version of the 1-up (extra life) sound effect traditionally used in the Super Mario franchise. I have two different Arduino codes used for the red variants: the 16-bit red mushroom contains a small segment of the Overworld Theme from Super Mario World for SNES, while the other red one uses the End-World Victory Music (after beating an Airship) from Super Mario Bros. 3. for NES. You're absolutely free to deviate from my musical codes and swap out any music you'd like, so long as you know how to tweak the Arduino code and manipulate notes. I personally recommend using the Super Mario World and Super Mario 3 songs for their corresponding mushrooms to maintain video game accuracy.

Please note before attempting this project:

  • Like all of my Instructables, this is not an easy nor cheap project to build. Although the LEGO and electronic portions are both significantly easier than the LEGO DL-44 Blaster I built in the summer of 2014, this isn't a project to be done by amateurs with little skill. Each Mushroom model contains roughly 300 LEGO pieces: some have slightly more or less depending on the particular color model. For instance, the green mushrooms have multiple shades of green and thus require more tiles. On average, I can't really give an estimation for the price, since I bought most of my electronics parts in large batches at once. Many of the pieces can be bought for less than $1 US from various online sources, and you'll probably spend about $10-15 worth of LEGO pieces, give or take.
  • The electronics skill required is novice-to-intermediate, but nonetheless requires the ability to solder and identify components (e.g. adhering to proper LED polarity, using proper resistors, using sufficient battery power).
  • Programming the sound chip requires a working Arduino board. I use an Uno, but from what I've gathered, the Mega and other models can be substituted.

Step 1: The LEGO Portion

For the sake of brevity, most of this information is copied verbatim from my similar tutorial for Electronic Super Mario Bros. Starmen.

The instructional guide for this section was generated with LEGO Digital Designer, which is a free program developed by LEGO Group for making virtual blueprints of original creations. Like in all of my other projects, the pieces acquired here were from a variety of sources, but mainly individually online through BrickLink.com -- essentially, it's an online "candy store" of LEGO pieces, where you choose parts based on type, color, or year in a catalog.

Download your chosen Mushroom model from the links below, and view the HTML guide with parts lists in the following links:8-bit Green (white with green dots, as seen in Super Mario 3), 16-bit Green (green with white dots, as seen in Super Mario World), 8-bit Red (white with red dots, as seen in Super Mario 3), and 16-bit Red (red with white dots, as seen in Super Mario World). As mentioned previously, both green Mushrooms play the 1-up sound effect in sync with the eyes flashing, whilst the two red ones have separate songs: 16-bit Red plays a segment from the main Super Mario World Overworld, and the 8-bit Red plays the victory music from Super Mario 3 when you've beaten an airship. Regardless of the model, the basic construction is exactly the same for each -- with the exception of the last remaining steps where you add the top layer of plates, tiles, and eye colors. Again, you're also free to deviate from my design and build a mushroom based on your own color schemes, like a purple mushroom for poison. In the various links above (which correspond to the various models), you'll see the step-by-step guides in HTML with a parts list as the last step. Regardless, the individual LDD files are contained in attachments in this step.

As I also point out in each of my LEGO Tutorials, LDD tends to produce the steps in random order and ends up having parts appear before other parts are intended to be added. Using your best judgement as a LEGO builder, always ensure your model is built securely and use your own design savvy to locate where the pieces should go. The bulk of the project is made from black plates and bricks, to form the mushroom sprite pattern. The innards are of course hollow, which securely house the electrical parts. Towards the end of the building steps, you'll begin placing plates and tiles on the front of the mushroom, according to your model's color design. Be sure to use the Technic plate in the direct center as specified: these holes are necessary for sound output. The final steps of the project contain the panel for keeping the tactile button in place: for some reason, LDD doesn't allow this particular irregular method of inserting Technic pins in the backs of bricks, hence the button panel appears as a separate component which should be added later (see the steps with the electronics).

Step 2: The Arduino Coding

Required tools:

  • 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. Most tutorials I've seen used various models.

  • ATtiny85 (through hole). You can get these for a little over a dollar (U.S.) from numerous online stores like Digi-Key, JameCo, and Sparkfun, but I bought about ten on eBay for $13. It's always good to buy multiple electronics parts: you're bound to accidentally break one or damage one somehow, especially if your skills aren't advanced enough. For instance, if you try to upload the Arduino code to your ATtiny but selected the wrong parameters, you'll permanently damage the chip.

  • Breadboard (any size): these range from $5-10 USD depending on size, and can be bought from Radio Shack or easily online.
  • Colored jumper wires: a decent set will cost about $10 USD.
  • One 10uF electrolytic capacitor - usually around $1.50 at Radio Shack, and like most parts are much cheaper online.

This section gets rather tricky for the novice, but for the advanced Arduino coder, this ought to be basic LED and tone functionality. Luckily all you have to do is upload my sketch to your ATtiny85 via a programmer of your choice. I personally used a setup called "Programming an ATtiny85 with Arduino", which uses a breadboard and some jumper wires. That aforementioned Instructable has links to the download files for installing the ATtiny master pack into your Arduino folder for boards. I've experimented with multiple tutorials for adding Arduino sketches to an ATtiny on a breadboard: some methods failed, and some worked -- and the method that worked perfectly was the one from the tutorial above, with ATtiny85 @ 1MHz (internal oscillator; BOD disabled) as the designated board for uploading finished sketches. I've tried various other ATtiny master packs from other tutorials, and had no luck -- and in some cases, I accidentally chose the wrong model (such as ATtiny85 @ 16MHz) and damaged my ATtiny. Always be sure to experiment with your Arduino itself before uploading the sketches directly to your microcontroller.

Programming the Chip:

  1. Before setting up your breadboard with parts, plug your Arduino into the USB port.
  2. Select the corresponding model from the dropdown menu -- mine is "Arduino Uno."
  3. From the examples menu, select a sketch called "Arduino as ISP". Upload that sketch to your Arduino.
  4. If it went successfully to your Arduino, place the 10uF capacitor between the GND and RESET female header slots on your Arduino.
  5. With your Arduino still connected via USB, set up your breadboard and Arduino configuration as per my images or from the images in the links above.
  6. Ensure your ATtiny85 is placed properly with the V+ and GND rails polarized, and the other wires connected to the Arduino's female header pins:

Arduino +5V ------> ATtiny Pin 8
Arduino Ground ------> ATtiny Pin 4
Arduino Pin 10 ------> ATtiny Pin 1
Arduino Pin 11 ------> ATtiny Pin 5
Arduino Pin 12 ------> ATtiny Pin 6
Arduino Pin 13 ------> ATtiny Pin 7

Now simply open your chosen mushroom sketch from my downloads links, choose the proper output from the Tools > Boards menu ("ATtiny85 @ 1MHz (internal oscillator; BOD disabled)") select "Upload Using Programmer", and wait until the sketch goes through. There might be two error messages about pagel files: these are to be expected, and if you just see these along with the "done" message, your sketch went through successfully. Remember, though: after uploading your sketch to the ATtiny, be sure to test it out on the breadboard by plugging in a speaker, LEDs, resistors, and a tactile button. If it works properly, it was a success, and you can remove the ATtiny and save it for when you build the circuit.

The three download links in this section contain your choice of sketches: the 1-up sound, the Super Mario World Overworld theme, or the Super Mario 3 airship victory music. All codes have essentially the same exact functions, such as blinking the LEDs in sync with the audio, only they're of course different songs -- and the red mushroom songs have some of their setup slightly adjusted to have different speeds and beats, and even some of the pitches adjusted. All codes will put the project in standby (power down) mode when not in use, and will be waken up immediately from tapping the tactile switch to replay the music/LEDs -- like a one-shot timer. Therefore, you can power this with as little as 3V in a coin cell, but I chose 6V to amplify the sound/light. If you'd like to change the music, you can do so by altering the notes and beat durations in the sketch. I have little or no knowledge of music, so I was able to successfully recreate the songs by downloading MIDI files from this website for Nintendo music, importing the MIDIs into Anvil Studio (freeware), and examining the individual notes/beats in the piano roll editor -- one note at a time. These mushroom sketches only allow for one tone to be played at a time, which means you can't have harmony nor chords. Most Mario songs have the tunes being played in multiple notes of harmony simultaneously, hence for my codes, I've used the middle notes. Both red mushroom songs unfortunately required several tracks of instruments and notes, thus I've reduced it to just the basic tunes.

Regarding my Mushroom sketch itself, it was an amalgamation of several sketches I've found online or in the Arduino IDE default library, only heavily modified to suit the needs for my code. The main sketch I've extracted my code from, however, was in this tutorial for making a musical Futurama Robot Santa statue by Psychic Origami -- in fact, I've even based the design of my Mushroom's internal circuit board off of his design as well. I've of course adjusted my circuits as well where applicable, and chosen some different variables.

Please note in regards to my Arduino melody notes: I've adjusted the note durations and note variables in each of the codes. If you look at the "notes.h" section, you'll see the beats assigned to variables: as the names suggest, BEAT is one standard note, HALF_BEAT is half a note, however QUARTER_BEATA is one quarter note, and QUARTER_BEAT is actually one eighth note -- the shortest note available. I changed these names while I was experimenting with notes, thus I never switched the name to "EIGHTH_BEAT" as it should properly be. That being said, you're certainly free to adjust the note durations and variables. I also think that I've slightly adjusted the Super Mario 3 victory music to be slightly slower than the Super Mario World Overworld theme.

Step 3: The Electronics Production

Required parts (aside from basic soldering irons, solder, cleanup gear, et alia):

  • Small Piezo speaker/transducer -- NOT a piezo buzzer, or else it'll produce a jarring sound like an alarm clock (in the proper notes/melody nonetheless, but still harsh). The small piezo speaker gives a subtle beep sound, like a musical greeting card. I purchased my speaker for 45¢ from this website (Surplus Electronics Sales), and because they were so cheap, I bought ten at once. Radio Shack sells piezo speakers for a few dollars, but they're much, much larger and thicker, yet produce a louder tone. They're still small enough to fit inside the Mushroom model, but I've chosen the tiny ones for saving space.
  • ATtiny85 (through hole). You can get these for a little over a dollar (U.S.) from numerous online stores like Digi-Key, JameCo, and Sparkfun, but I bought about ten on eBay for $13. It's always good to buy multiple electronics parts: you're bound to accidentally break one or damage one somehow, especially if your skills aren't advanced enough. For instance, if you try to upload the Arduino code to your ATtiny but selected the wrong parameters, you'll permanently damage the chip.
  • 8-pin DIP socket. These are small sockets to solder on to your circuit for housing the ATtiny85, rather than soldering your ATtiny85 directly to the board -- this way, you can replace the AVR and re-upload code. I'm pretty sure Radio Shack sells these for like 2 for 50¢, so online you're bound to get these in batches for cheap.
  • 5mm white LEDs (or green color, really) for the green mushrooms, or 5mm red LEDs for the red models. Previously I'd use straw hat LEDs, since they'd fit snugly into a LEGO Technic hole, but for these new mushrooms I've actually used standard 5mm LEDs -- which require some force to keep in place of the hole, but from I've learned, they actually stay in better and don't fall out. In the photos attached, I've used the straw hat LEDs from the Starman tutorial to save time, but in these mushrooms I have in fact used 5mm standard LEDs -- you can use whichever you decide to use.
  • 100 Ohm resistors for the LEDs. I tend to use this kind for most of my LED applications with low-voltages, and nothing burns out nor malfunctions. Resistors are super cheap, and Radio Shack sells them in packs for a few dollars U.S.
  • Coin cell holder for two 20mm cells. This is the model I've bought on Digi-Key for $1.18. If you plan on only using 3V, be sure to order the same thing for holding one cell.
  • Two CR2032 coin cells. Most stores like Radio Shack, Staples, and Best Buy tend to have a lot of markup on these batteries like charging $8 for just two, so I bought several online for half the price. I found some electronics dealers on eBay, Amazon, or third-party stores that can sell generic ones from China or Thailand for as little as $13 for 20. Also, keep in mind that I constructed six mushrooms simultaneously, hence I did in fact need a ton of these batteries to play with. If you only plan on making one and don't require a king's ransom of 3V coin cells sitting around, just go ahead and pick up a two-pack from your nearest store that sells watch batteries. I think even Home Depot, Rite Aid, and CVS sell these, but again they're pricy at major retailers, especially name-brand Duracell and Energizer CR2032 cells.
  • Small tactile push buttons -- not an on/off toggle. These are the tiny tactile buttons commonly used in most Arduino applications. The claw-like connectors on the backs are vital for holding into place of the LEGO grille tiles of the rear of the mushroom's head. These cost super cheap;I bought mine for 15¢ each on Digi-Key.
  • Small perforated circuit boards. The final size of your completed circuit should be around 1.75'' (~4.5cm) square, give or take. Radio Shack sells miniature perforated circuit boards for a few dollars U.S., however I bought mine from eBay, for about $7 for 20. Naturally, once your board is soldered and completed, simply trim around the excess areas with wire cutters or powerful scissors, and the board should snap off directly in the path you cut. The key is to compact the board as much as possible, to properly fit it inside the Mushroom. Your completed board should be no more than 5 LEGO studs square!
  • Breakaway female header pins. These are what you'll be placing on your circuit to insert/remove the LEDs and speakers. I dislike permanently installing lights and speakers into my circuits, hence I generally use female header pins for interchanging crucial items. For instance, if an LED burns out, you simply disconnect it. I purchased several rows of female header pins for less than $10 on eBay, and using an X-acto knife, you can slice off the pins you need for your circuit.
  • Thin jumper/bus wire, preferably high gauge like 24-30 AWG. Spools of this can cost a few dollars U.S.; I choose red/black to distinguish +/- connections on my circuit, respectively, or for placing on polarized components such as LEDs. I use non-insulated tin bus wire for small short connections in my circuit, like connecting the header pins to the ATtiny85. Non-insulated tin bus wire should only be used when you're certain that no other non-insulated wires will come in contact with it, otherwise you'll create a short circuit. When having multiple wires go across each, always make sure they're insulated, and be sure to have red/black color-coordinated ones to avoid confusion with V+ and GND connections.
  • Helpful, but not required: a small vice, or "third hands" -- these are mini alligator clips used to suspend circuit boards off your work desk, for being able to use both hands with soldering. These retail anywhere between $10-30, but really streamline your production.

This section makes the assumption that you're familiar with soldering, as well as using component parts in a circuit. If you're having trouble creating circuits, please refer to this handy Instructable for beginning soldering. That being said, you're now ready to move on and build the circuit.

Refer to my breadboard diagram above. I chose not to make a Fritzing diagram, as it's difficult to convey the method of having the LEDs connected to header pins via wire, let alone how to convey the female header pins in general (after all, the Fritzing software's breadboard is basically just one huge series of female header pins, anyway). That being said, my breadboard diagram above is a hybrid design of a breadboard and a schematic, with everything simplified enough for amateurs, but detailed enough for experienced electronic builders. Like all electronics projects, always experiment with a breadboard first, just to see if your circuit will even work to begin with. If you're satisfied with your breadboard, you can map out where to place components on the circuit board. Do a dry run to map out where the parts will be placed with the best space-saving options; refer to my photo of a completed circuit with batteries. Before soldering, place the 8-pin socket on the board first, then put on the battery holder, followed by the resistors (corresponding to the respective ATtiny85 pins), finally the female header pins. If your dry run circuit resembles mine, then feel free to use a pencil to mark the locations to permanently solder the parts, then begin heating up your iron!

Start with soldering down the two most vital parts: the 8-pin socket for the ATtiny85, and the battery holder. You don't have to solder each pin of the 8-pin socket, just the ones vital to the circuit (see my illustration: for instance, the first two bottom row pins on the ATtiny serve no use for this project). Attach the two resistors, however, you can save time by omitting them and simply attaching the resistor to the wire for the LED; it's your choice. I personally placed the resistors in permanently connected to the pins of the 8-pin socket, which then leads to a slot in the female header pins. For the first LED, cut a section of two female header pins: this will be used as the terminal for the first LED. Have one pin of the header pins connected to the resistor (+), and the other will lead to the ground terminal (-). Your LED's respective pins will then be placed in these slots: the positive pin in the slot connected to the resistor, and the negative pin in the slot that goes to the ground terminal. Cut six female header pins: this row of six slots will be used for the second LED, the speaker, and the switch. Like the previous row of header pins, make sure the ones on the left of the row begin with where the resistor is connected, as this will be the positive slot for your LED, with header pin 2 leading to the ground terminal. Header pin 3 will be the slot for the red wire for your speaker, and header pin 4 will hold the ground wire for your speaker (connect header pin 3 to the ATtiny, and header pin 4 goes to ground). Header pin 5 will be connected to the ATtiny for the switch, and likewise header pin 6 goes to ground -- use these final two slots for eventually keeping the two wires for the switch. Once everything is properly soldered down, you can then move forward by attaching the removable components to test: insert the two batteries, the ATtiny85, the switch, the speakers, and the two LEDs. Tap the button to see if everything works, and if it's a success, remove the speakers, LEDs, and switch (but keep the batteries and ATtiny85 inserted), trim off the excess circuit board, and place the completed circuit into the back of your Mushroom!

For the LEDs, I've soldered on each pin about an inch of thin insulated wire. Also, if your wires are too thin, go ahead and solder a tiny piece of slightly-thicker tin bus wire to the ends of the LED's wires, so that they stay snug in the female header pins. If there's an excess of wire from the speaker, then either trim them down or wrap it around the circuit when placing it into the Mushroom. Cut about 3 inches of thin insulated wire and solder then to the tactile pushbutton (diagonally -- refer to my photo). The button and its wires will go on last, as it requires further assembly of the LEGO portion before being sealed off.

Common electrical problem: the ATtiny has a primary ground pin (pin 4), but pin 3 can act as a ground pin as well, yet pin 3 is reserved for the first LED. Since the first LED on pin 3 is grounded to the battery's ground terminal, this completes the whole circuit, but since the ATtiny is only partially grounded, it's as if your circuit is in a series instead of being in parallel, hence the LEDs will be dull and the sound is quiet -- making it seem as if your batteries are dying. In addition to pin 3's LED being properly grounded, always ensure the ATtiny85's pin 4 is grounded as well -- this makes the circuit truly complete, and the sound/lights function as intended. In other words, the ATtiny's 8th pin goes to positive, the 4th pin goes to negative, and the other pins connect to their respective components (which ultimately lead to ground as well). When I made the first circuit, I forgot to solder pin 4 to ground, thus my circuit functioned -- but rather dull and quiet, which led my initially to believe either the batteries were duds or that I improperly made the connections.

Step 4: Assembly

Although your mushroom is now fully built, before completing all of the electrical assembly steps below, I'd recommend removing some of the rear plates (as seen in the photos), so that you have complete access to the innards. Eventually after you've installed the circuit and wires, you'll seal off most of the rear of the mushroom, while keeping an easy-to-remove door on the back for changing batteries.

With your small circuit complete, next you can insert the piezo speaker into the proper slot of female header pins (the piezo is non-polarized, hence the wire colors don't matter), then place the module into the back of the mushroom model with the back exposed (see photos). The piezo speaker's front hole should face up against the Technic hole for sound output. If you've used the exact same model piezo speaker as me, it should be able to snap in place directly between the eyes. Then place the two LEDs in the proper spots on the header pins, and use some needlenose pliers to carefully place them in if need be. Gently push the LEDs into the two Technic holes corresponding to the mushroom's eyes; dome-shaped straw hat LEDs ought to stay in place, but as I've learned in this model, standard 5mm fit in snug with a gentle push -- but make sure not to push the eyes out of the socket. If you've used smaller LEDs, feel free to add any pieces you feel necessary to hold the LEDs firm into the eye sockets, and you can even use tape or hot glue if you'd like.

On the back of the mushroom's head is where the 4x3 grille thing (from your LDD file) should go, as shown in the third photo. The grille tiles will successfully hold in place a small tactile switch's claw-like legs, which should have the two wires soldered to them. Snake the wires through the grille and down into the back of the model, and use some needlenose pliers or tweezers to guide them into the female header pins. The tactile switch is also non-polarized, which means either of the wires can go in the two female header pins on the right, as +/- doesn't matter (it only matters that at least one wire is connected to the ATtiny's 5th pin, and the other to ground). Everything should be well attached, so give the button a press to see it blink and make sound!

Remember: any two metal components on a circuit that unintentionally make contact with each other will short out the circuit. For instance, if the anode and cathode of the same LED were to get too close and touch each other, the lights would go off. If the speakers have exposed wires which are too close to the switch's potential exposed wires, the circuit will fail. Always be sure to use insulated wire where possible and to ensure any exposed wire is properly covered. In my circuit in the photos, clearly my header pins have a lot of exposed wire from the speakers, LEDs, and switch, as I didn't have time to trim them before the photo shoot; to avoid short circuits, I've bent the wires away from each other, so that they won't come loose and jiggle around inside. If you have excess exposed wire, you can either trim them, or wrap them in electrical tape -- or if you're truly ambitious, you can glue the wire connections into the female header pins, as hot glue around the wire will secure any potential short circuits.

The "battery door" is a flat 4x10 LEGO plate with four 1x1 plates in the corner: this makes it easy to remove the battery door, whilst keeping it secure for the back. When the mushroom is complete, you can place the flat plates on the back, and the final model ought to be functional and self-contained. If anything comes loose and jiggles around, always take the back off and examine what you did wrong: perhaps you made the circuit board too small, which isn't held firmly in place enough, in which I'd recommend stuffing the inside with some various plates and bricks to hold the circuit/wires down snugly.

Step 5: These LEGO Models Will Make You a Fungi (get It, "fun-guy?" Nevermind)

Despite my best efforts, the red mushrooms won't make you get any bigger, and the green ones won't bring you back to life after you've fallen off a cliff (trust me, I tested it -- but luckily my Invincibility Starmen kept me safe)!

Since only the black LEGO bricks/sprites are semi-mandatory for the bulk of each model, you're free to deviate with the color schemes, eye colors, and LED colors as well -- and you can even mess with the Arduino code to play different melodies from the Super Mario franchise (or any song, really, assuming you can convert notes to tone)!

Feel free to ask any questions where applicable if you run into any problems with either the LEGO construction, the Arduino code, or the electronic soldering. Also go ahead and share in the comments section your completed Mushroom models, to display your talents and to show off any changes/improvements you've made!

-Baron von Brunk

Credits:

Design, photography, video editing, and electronic work by Baron Julius von Brunk
LEGO® is a trademark of the LEGO Group
Super Mario Bros.® is a registered trademark of Nintendo
All songs composed by Koji Kondo

Microcontroller Contest

Participated in the
Microcontroller Contest

Make it Glow!

Participated in the
Make it Glow!

Formlabs Contest

Participated in the
Formlabs Contest