HackerBox 0074: Battle Axe

by HackerBoxes in Circuits > Arduino

4120 Views, 11 Favorites, 0 Comments

HackerBox 0074: Battle Axe

Whole Box HB0074.png

Welcome to HackerBox 0074. We will configure the ATmega32U4 Pro Micro Module for USB HID operations. Explore use of the Pro Micro as a tool for keystroke injection exploits. Assemble the three-piece Battle Axe badge featuring two types of RGB LEDs, seven mechanical clicky keyswitches, and an on-board speaker. Program the Battle Axe as a specialized macropad.  Connect the Battle Axe as a game controller for Clone Hero and other music games that really rock!

HackerBoxes is the monthly subscription box of electronics, computer technology, and hacker culture. Each HackerBox is a discovery box, which means all members await and enjoy a new surprise each month. Tech, toys, knowledge, and fun... It's like having a hacker convention, your birthday, and the first day of school - every month - right in your mailbox.

There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we'd really appreciate it if you can take a few minutes to read the FAQ.

Supplies

Whole Box Guitar Assembled.png

This Instructable contains information for getting started with HackerBox 0074. The full box contents are listed on the product page for HackerBox 0074 where the box is also available for purchase while supplies last. If you would like to automatically receive a HackerBox like this right in your mailbox each month with a $15 discount, you can subscribe at HackerBoxes.com and join the party!

A soldering iron, solder, and basic soldering tools are generally needed to work on the monthly HackerBox. A computer for running software tools is also required. Have a look at the HackerBox Workshops for basic tools and a wide array of introductory activities and experiments.

The most import thing you will need is a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.

Arduino Pro Micro ATmega32U4

Pro Micro.png

This ATmega32U4 Pro Micro Module features a USB-C interface and can be programmed through the Arduino IDE. If you don't have the Arduino IDE, download it now. As always, we strongly suggest that you configure the IDE and run some test code on the Pro Micro before soldering anything.

The built-in support for the "Arduino Micro" should also work for the "Arduino Pro Micro".

Select:

Tools > Board > Arduino AVR Boards > Arduino Micro

Tools > Port > [USB COM port associated with the Pro Micro]

As usual, we now open up the blink example:

File > Examples > Basics > Blink

Unlike usual, we have a little problem. There is no LED_BUILTIN on the Pro Micro. Luckily there two LEDs for showing the status of the serial TX and RX lines. We can just borrow these.

In the Blink sketch, change LED_BUILTIN to 17 in three places. Compile and upload.

During the upload, both of the serial port LEDs will flicker on the Pro Micro. Once the upload is complete, one of the LEDs will continue slowly blinking forever. This is the blink sketch at work. On our current Pro Micros, the LED on pin 17 is green, but it might had a different color LED depending upon the Pro Micro batch being used.

For fun, let's repeat this exercise changing pin 17 to 30 (in all three locations). Compile and upload. Once the upload is complete, the other serial LED will continue slowly blinking forever. On our current Pro Micros, the LED on pin 30 is blue, but again, your mileage may vary.

PRETENDING TO BE A KEYBOARD

We're specifically using the ATmega32U4 microcontroller because it features an integrated USB transceiver. Among other things, this means that our Pro Micro module can emulate a human interface device (HID). Or, in plan English, it can easily pretend to be a USB keyboard or mouse. This will come in handy for using our Battle Axe Badge as a controller for music games that REALLY ROCK. Before we go there, you may want to leverage this same HID functionally to play around with keystroke injection. For example, try Duckino to "compile" Ducky Script into Arduino code that can run on your Arduino Pro Micro.

TROUBLESHOOTING (OPTIONAL IDE SETUP)

If using the built-in Arduino Micro support gives you trouble, Sparkfun has a great Pro Micro Hookup Guide that might help. If you end up using that, you will need to select:

Tools > Board > SparkFun AVR Boards > SparkFun Pro Micro

Tools > Processor > ATmega32U4 (5V, 16MHz)

WARNING: DO NOT select the 3.3V version of the SparkFun Pro Micro or the module will get bricked. Of course, this warning only applies when using the SparkFun board package. If the 3.3V settings are used, the IDE upload will work once and then the Pro Micro will appear to not connect to your PC (it will be bricked). Luckily, this can be fixed by shorting between two pins of the Pro Micro to reset the bootloader just before initiating a download. Short between the RST and GND pins using the end of a wire or small flathead screwdriver. The tricky part is that you actually need to "double click" the connection by shorting and releasing twice in quick succession. Getting the timing right might take a few tries. See the "Troubleshooting" section of the SparkFun guide for more info.

Assemble Axe Body - SMD Parts

Axe Body SMD.png

If necessary, review the SMD Soldering Video. (SMD = Surface Mount Device)

TWO SK6812MINI-E RGB Reverse-Mount SMD LEDs

Start on the BACK of the PCB. This means have the word HackerBox down against the table.

Get out the strip of 8 SK6812 Reverse-Mount LEDs (these are the white ones).

Remove two LEDs from the strip.

Each LED has four leads sticking out. One lead has a corner cut off. That is the GND pin.

Find the two small square holes where these LEDs go.

Note the small white mark on one corner near the square hole. That corner is where the GND pin goes.

Make sure the LED GND (corner cut off) matches the PCB GND (white marking).

Make sure the window side of the LED (where the light will come out) faces down through the PCB.

Carefully solder all four pins of each LED.

SIX WS2812B SMD5050 RGB LEDs

Flip the PCB to the front side. This means have the word HackerBox facing up.

Get out the strip of 16 WS2812B LEDs (these are the black ones).

Remove six LEDs from the strip.

Rotate the PCB so the word HackerBox is across the top and the axe blade is along the bottom.

In that orientation, the GND pin for each LED is towards the upper left - as illustrated. 

Each LED has a white triangle on one corner of its housing. That corner is where the GND pin is.

Make sure the LED GND (white triangle) matches the PCB GND (upper left) as illustrated.

Make sure the window side of the LED (where the light will come out) faces out from the PCB.

Carefully solder all four pins of each LED.

Assemble Axe Body - Through-Hole Parts

Axe Body TH.png

PCB Mounted Speaker

The black housing of the speaker goes on the same side of the PCB as the six black LEDs.

Note the markings on the speaker showing which pin is positive.

Note the markings on the PCB showing which mounting hole is positive.

Put the positive pin in the positive hole. (Thank you, Capt. Obvious!)

Solder both pins of the speaker.

TWO Keyswitches

Two of the nice clicky keyswitches go on the same side of the PCB as the six black LEDs.

A center peg on the bottom of each switch forces the alignment into place.

Note how the reverse-mount LEDs will shine up through the switch housing.

Solder the two pins of each switch.

ATmega32U4 Pro Micro Module

The Pro Micro Module goes on the back of the red PCB (opposite side from the speaker).

The Pro Micro must be oriented so that the USB port opens out to the edge of the red PCB.

The two header strips are placed between the Pro Micro and the red PCB.

The short pins of the header strips go through the Pro Micro.

The long pins of the header strips go through the red PCB.

Keep the Pro Micro pressed against the red PCB while carefully soldering the corner pins.

Each pin must be soldered on both sides - outside the Pro Micro and outside the red PCB.

Once the four corner pins are soldered and everything is tight, solder all remaining pins.

Trim Leads (WEAR SAFETY GLASSES)

The two leads on the back of the speaker can be trimmed flush.

The two rows of header pins extending from the top of the red PCB can also be trimmed.

Leave the short pins on the Pro Micro side alone.

After trimming through-hole leads, it can help to smooth the "wound" over with a hot iron.

Program the Pro Micro

Grab the attached BattleAxeTest.ino sketch.

This sketch requires the FastLED library.

Go to: Tools > Manage Libraries

In the window that opens, search for FastLED and hit install.

Compile and upload the sketch to the Pro Micro.

The six WS2812 LEDs should color cycle.

Pressing a keyswitch should blink the LED under it and emit a brief tone from the speaker.

Downloads

Assemble Axe Neck

Axe Neck.png

The Axe Neck PCB gets NINE WS2812B LEDs (these are the black ones).

Note the small white silkscreen marking on the PCB for each LED.

Align each LEDs GND pin (white triangle) with the white marking on the PCB.

Assemble Axe Head

Axe Head.png

The Axe Head PCB gets FIVE reverse-mount LEDs and FIVE keyswitches.

FIRST: Mount the FIVE SK6812MINI-E RGB Reverse-Mount SMD LEDs

Follow the same process used on the Axe Body...

Make sure the LED GND (corner cut off) matches the PCB GND (white marking).

Make sure the window side of the LED (where the light will come out) faces through the PCB.

SECOND: Mount the FIVE Clicky Keyswicthes

The bodies of the switches go on the side of the PCB with the rope silkscreen graphics.

The pins of the switches are soldered on the same side of the PCB as the LEDs.

Attach Three Axe PCBs

Connect Three.png

Follow the guideline in the image to position the three Battle Axe PCBs together:

The neck (middle) PCB goes behind other two PCBs.

The triangle markings on the middle PCB must point away from the red PCB and towards guitar head.

Double check the positioning before soldering.

The PCBs are attached using header pins in four places as shown according to the following procedure:

  • Cut four sections of nine header pins each
  • Place a section of pins through both PCBs from the back
  • Make sure the plastic insulator is on the bottom side of the PCB stack
  • Solder all nine pins on the top side (opposite the plastic insulator)
  • Gently rock the plastic insulator off the back side of the pins
  • Solder the back side of the pins while holding the PCBs tightly together
  • Trim the pin leads flush against the back of the PCB stack
  • It's fine to leave the pin leads on the front of the PCB stack
  • Smooth over cut lead "wounds" with a hot iron
  • Repeat for all four sections of nine header pins

Test and Debug

The Pro Micro should already be programed with the BattleAxeTest.ino sketch we tested earlier. If not, program it now.

When the sketch runs, all of the WS2812 LEDs should do some color cycling.

When a key is pressed, the LED under that key should blink and the speaker should emit a brief tone.

Test all seven keys - one at a time.

There are two chains of LEDs (one for each type). If either chain of LEDs does not fully illuminate, check the soldering at the last working LED in the chain and at the first non-working LED. Make any corrections to properly establish the LED chain.

The BattleAxeTest.ino sketch is fairly simple. It illustrates how we can read the keys, backlight the keys in different colors, make different sounds, and light up the 15 black WS2812 LEDs.

Can you implement a "Simon Says" game like we did way back in HackerBox 0044?

Guitar Keypad

Guitar Keypad.png

Arduino Pro Micros are often used to create macropads as in this example. A macropad is just a small keyboard with keyswitches dedicated to common tasks useful for streamlining workflow.

The Battle Axe Badge is basically a seven-key macropad shaped like a weird electric guitar.

Grab the GuitarKeypad.ino sketch attached here.

Use Tools > Manage Libraries in the IDE to locate and install the Bounce2 library.

Compile and Upload the sketch.

Open a notepad on your PC and test out all seven keys of the Battle Axe. They should match the five letters, up arrow, and down arrow as illustrated here.

The keys assigned in the sketch can be changed to whichever you'd like. The reason for such seemingly odd initial key settings is that they are the default controls for Clone Hero...

Downloads

Clone Hero

Clone Hero.png

Clone Hero is a free music game. It is a clone of Guitar Hero with nearly identical gameplay. The main draw of the game is its ability to play community-made songs (called charts), which has resulted in a large fan community.

Download the game, copy your song charts into the song folder and enjoy hours of fun!

Can't Stop the Rock

outro.png

We hope you are enjoying this month's HackerBox adventure into electronics, computer technology, and hacker culture. Reach out and share your success in the comments below or other social media. Also, remember that you can email support@hackerboxes.com anytime if you have a question or need some help.

What's Next? Join the party! Live the HackLife! Get a cool box of hackable gear delivered right to your mailbox each month and enjoy a generous member discount. Surf over to HackerBoxes.com right now and sign up for your monthly HackerBox subscription.