How to Control the LEDs on a Novation Launchkey Mini II

I picked up a Novation Launchkey Mini II controller last year when I was working with those musical floppy drives, and recently I fell down the rabbit hole of Launchpad LED performance videos. That got me thinking: is it possible to control the LEDs on a Launchkey Mini like you can on a Launchpad?

There’s surprisingly little information about this. Novation’s user guide for the Launchkey Mini has no mention of how to control the LEDs. There is some information available in a “programmer’s reference” manual for the Launchkey II (not the “Mini” version), but sadly the LED components don’t function the same way.

It required a bit of reverse engineering and the result isn’t quite as pretty, but I’ve figured out how to do it.

Continue reading “How to Control the LEDs on a Novation Launchkey Mini II”

Playing Lucio with a DJ Hero Turntable

Earlier this year while I was hard at work on the Nintendo Extension Ctrl library, I challenged myself to try and support as many different types of controllers as possible. As a part of that I picked up a DJ Hero controller for the Nintendo Wii on Ebay for $10.

And then it hit me: with a little bit of effort, I could write some code that would allow me to play the character of Lucio in Overwatch using this turntable! So that’s exactly what I did.

Continue reading “Playing Lucio with a DJ Hero Turntable”

Nintendo Extension Ctrl Breakout Board

Now that the library is finished, it’s time to start putting it to use! The first step is building a better breakout board for connecting to the extension controllers.

Existing Breakouts…

From what I could find, there are two types of common breakout boards currently in use: the “stick” breakout and the Nunchucky breakout.

The “stick” breakout is exactly what it sounds like: a regular old breakout in the shape of a stick. This is designed to be manufactured dirt cheap and plug into the Arduino Uno’s analog pin header. It’s manufactured and sold by a bunch of different Chinese companies.

The Nunchucky breakout is what I used for the McCree Hammershot’s Nunchuk support. It’s a larger rectangular board, with an additional pin strip for adding a female header and notches to hold the extension controllers’ retaining clips. This is by far the better option of the two, but it’s still lacking.

…Existing Problems

These breakouts are a great starting point, but they do have their issues. There are three problems that need to be addressed:

#1 – Power Before Data

For some reason, both of these breakouts have all six of their gold contact fingers at the same length. The vast majority of multi-pin connectors have two pins that are longer than the others so that power and ground make first contact. Otherwise when plugging in a device to a ‘hot’ connector, it’s a gamble which two pins will make contact first, sending power in unpredictable and usually undesirable ways.

For the Nintendo extension controllers, the shorter pins are on the receptacle and not the plug. Available breakouts do not abide by these conventions.

#2 – Controller Detect

The Nintendo extension connector has a loopback functionality that connects pin #5 to VCC, allowing the Wiimote to detect whether an extension has been connected without attempting to talk to it over I²C. Neither breakout exposes this pin.

#3 – Data Pull-ups

As each extension controller has varying bus capacitance based on their design, the pull-ups for the I²C bus are on the extension controllers themselves and not the base unit. Nevertheless, the microcontroller requires some small pull-ups so that the bus doesn’t hang if the controller is disconnected. Current breakouts have no pull-ups of any kind, instead relying on the microcontroller to use its own internal pull-ups which are sometimes not available.

The NXCtrl Breakout

The NXCtrl breakout solves all of these problems! The 4 non-power fingers are set back 1 mm from the board edge to ensure the controller powers up before anything else. The “controller detect” pin is exposed with a 10 kΩ pull-down resistor for easy use with most microcontrollers. Finally, both the SCL and SDA lines have 47 kΩ pull-up resistors to prevent the I²C lines from floating if a controller is disconnected. When combined with the typical 1.9 kΩ pull-ups in the Nunchuk and Classic Controller, these give the system a total pull-up strength of roughly 1.8 kΩ.

NXC breakout panel, straight from OSH Park using their auto-panelization.

I ordered a batch from OSH Park and hand soldered the three resistors. I’ve been testing these breakouts with my latest projects, and so far they’re doing really well – they’re easier to set up than the other breakouts and having access to the controller detect pin is quite useful. This may only be version 1.0, but I don’t think I would change a thing. The layout is good, the silkscreen is clear, and the cutout for the connector is spot-on.

I’ve got at least two projects using these breakouts in the works. Watch this space!

Nintendo Extension Ctrl Library

Late last year when I was putting the finishing touches on the McCree Hammershot project, I decided to use a Wii Nunchuk hooked up to an Arduino for the controller’s movement. Although I eventually got it working, I had to try a variety of libraries before I found one that would even read the data properly. Most of them were convoluted, bloated, or poorly documented. Even the library I eventually ended up using was designed for controlling motors with a Nunchuk, not for just reading control inputs.

It’s now many months later, and once again I’m looking to build at least two more projects using extension controllers. So I decided to fix all of these problems and just build my own library.

Continue reading “Nintendo Extension Ctrl Library”

Building a DIY Stream Deck (Mini Macro Keyboard)

I’ve been doing a little streaming on Twitch (hiya!), and a lot of streamers I follow have something called an Elgato Stream Deck. The Stream Deck is a small device with 15 buttons, each of which has its own customizable RGB icon. By configuring the bundled software, users can set button icons and macros to control your casting software, send messages in the stream chat, launch programs, and much much more.

Unfortunately the Stream Deck is out of my price range, at a whopping $149.99 retail.  Fortunately I think I can make something that replicates the basic functionality for a fraction of that price: what I’m calling a “Stream Cheap”.

Although I’m focusing on using this as a replacement for a Stream Deck, at heart this is really a custom macro keyboard. It could be used as a hotkey board for any program. I’m just using it for OBS and Twitch.

Continue reading “Building a DIY Stream Deck (Mini Macro Keyboard)”

OBS Studio Chat Hotkey Script

As a tie-in to my DIY Stream Deck, I wrote a Python script for OBS Studio that allows you to send messages to Twitch chat using OBS’s built-in hotkey system.

Scripting

The 21.0 update for OBS added support for Python and Lua scripting, using a new scripting console and an extension of the C API. In the words of the developers, scripting allows you to “quickly extend, add features, or automate the program without needing to build a native plugin module.”

Since my non-embedded C++ still needs some work, I decided to try writing this program as a Python script rather than a C++ plugin.

Setting Properties

Via the scripts window, the chat script has access to Qt GUI elements in OBS such as text boxes, lists, and buttons. The user can fill in these fields to customize the script without having to modify any configuration files. With the initial release of the script, these configuration options include:

  • Channel: the channel on Twitch to post messages in
  • User: the username of the user posting messages
  • Oauth: the access key required for authentication to Twitch servers
  • Messages: the custom list of messages that can be sent

These settings are stored with the rest of your OBS settings and are reloaded on startup. There are also two buttons on the bottom of the panel for testing authentication and test sending the first message in the list.

(Note: I wanted the test message button to use the user-selected message in the list, but that property doesn’t appear to be exposed by the API, at least not yet.)

Hotkey Hooking

Each message added to the message list gets its own custom hotkey that can be modified in the OBS settings window. These work like any other hotkey in the program and are saved with their message in the script settings.

The list of messages is extensible, and will add / remove hotkeys as list items are changed. Reordering the message list will also reorder how items appear in the OBS hotkey settings.

Talking to Twitch Chat

Aside from the OBS API functions, the real meat of the script is the code for communicating with Twitch chat itself. Twitch chat is just IRC, so I’m using Python 3’s built-in socket library to handle all of the networking.

After a hotkey has been pressed, the script will open a connection to the Twitch server, authenticate, and then send a message. With version 1.0, this connection is released after a short period to avoid overhead and let repeated messages through without re-authenticating. All messages are rate-limited to the global limit based on the system time, which prevents the user from accidentally receiving a temporary site-wide chat ban for spam.

Any network errors are raised as exceptions if a test button is pressed, but are suppressed if triggered from a hotkey message. This is to alert the user if there is a problem during setup, but otherwise hide issues to avoid interruptions during streaming.

Using the Script

If you’d like to use the script yourself, it’s quite easy. Download the script from GitHub or the OBS resource page and follow the instructions in the README. By far the most difficult part is getting the OBS scripting console to work. You will need to install Python and point OBS to the installation directory. If you load the script and no properties appear, the Python installation / link is not set up correctly.

The script is licensed under GPL v3; it’s free software, so you can use it, modify it, and distribute it so long as you abide by the license.

Although I think it’s obvious, I’ll stress here that this is a 3rd party plugin for OBS. I have no affiliation or endorsement as a developer from either Twitch or OBS.

Conclusion

This was a fun script to write, and it makes me want to see what else I could with OBS scripting / plugins in the future.

I may end up converting this to a C++ plugin at some point, to avoid users having to install and configure Python to use it. But that’s a project for another day.

DIY PC Footswitch Using a Sustain Pedal

A couple of years ago I picked up an inexpensive sustain pedal for an electric piano at a garage sale. The piano itself wasn’t much to look at, but the pedal intrigued me… it’s a basic on/off switch, but the pedal itself feels fairly robust and I thought it would be a handy switch to have around.

This past week I finally got around to doing something with it! I built a small box that converts the signal from the pedal into a keypress, allowing me to use this pedal as a foot-controlled hotkey for my PC.

Continue reading “DIY PC Footswitch Using a Sustain Pedal”