This example will only work with Windows 11. Windows 11 is the only OS that currently has built-in Dynamic Lighting controls.
If you dabble with any computer accessories with RGB LEDs then you may be familiar with the countless tiny tool tray background apps that you end up running to control your Super Gamer Brand Mouse and your Mega Gaming Brand Keyboard and your Epic Games PC Case Fans. The HID LampArray protocol attempts to build and implement one LED protocol to control them all and the best part is, as the name implies, it's over USB HID.
You can use the Pixel Trinkey as an HID LampArray device. This means you can control your attached NeoPixels with the click of a mouse with the Dynamic Lighting settings in Windows 11.
Connect your NeoPixels to the terminal block on the Pixel Trinkey:
- Board GND to NeoPixel GND (black wire)
- Board DATA to NeoPixel DATA IN (blue wire)
- Board +5V to NeoPixel VIN (red wire)
Software
Microsoft has an Arduino library, ArduinoHidForWindows, that has support and an example for HID LampArray. However, there is a catch: this library only supports the Arduino SAMD board support package and throws errors when you try to compile with the Adafruit SAMD board support package because of differences in how it wants to handle USB.
Worry not! There are two options for you as a result: use a precompiled UF2 to drag and drop onto the Pixel Trinkey for instant HID LampArray or, for more advanced hackers, install the modified Arduino SAMD board support package with the Pixel Trinkey to fully customize the code for your needs.
UF2 Option
There are two UF2 options: one for RGB NeoPixels and one for RGBW NeoPixels. Both options are built for 64 pixels. This should cover the needs for most folks and will let you at least start to experiment with Dynamic Lighting.
Click the link above to download the UF2 file for either RGB or RGBW NeoPixels. Save it wherever is convenient for you.
Plug your Trinkey into your computer directly.
Double-click the reset button (highlighted in red above), wait about a half a second and then tap reset again. You'll see the NeoPixel turn green.
The code will begin running and you'll be able to start controlling the Pixel Trinkey NeoPixels with Dynamic Lighting!
The first time that you connect the Trinkey with the HID LampArray firmware, you'll see a message pop up in the bottom right corner letting you know that Windows has found a new Dynamic Lighting device.
Navigate to Settings - Personalization - Dynamic Lighting. You'll see the Pixel Trinkey M0 as an available device. Click on the Pixel Trinkey M0 icon to access lighting controls for it.
There are quite a few effects that you can set with just a few clicks of a mouse for your NeoPixels. You can set a solid color and even have the color match your Windows accent color.
There are a lot of parameters that you can customize within the Dynamic Lighting page. The animations and settings are responsive and are definitely a breath of fresh air from endless tool tray apps.
The following section requires knowledge of the Arduino IDE and may be complicated for beginners.
As mentioned earlier on this page, the ArduinoHidForWindows library only supports the Arduino SAMD board support package and throws errors when you try to compile with the Adafruit SAMD board support package because of differences in how it wants to handle USB. These steps will guide you through installing a modified version of the Arduino SAMD board support package and installing the ArduinoHidForWindows library.
Download and unzip the modified board support package from the link above. Save the folder in the hardware/ folder inside of your Arduino/ sketches folder. The folder structure should be /your/path/to/Arduino/hardware/samd/1.18.14-pixelTrinkey
Quit and reopen the Arduino IDE to ensure that the newly installed board support package populates correctly. You should now be able to select and upload to the new boards listed in the Tools->Board menu.
Select the Arduino SAMD Boards (in sketchbook) option and then select Adafruit Pixel Trinkey M0.
Library Installation
You can install the ArduinoHidForWindows library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Microsoft HID, and select the Microsoft_HidForWindows library:
If you haven't done so already, install the Adafruit NeoPixel library as well by searching for Adafruit NeoPixel and selecting the Adafruit NeoPixel library:
There are no additional dependencies for either library.
The code above is the code used for the UF2 files. With the modified board support package and library installed, you should be able to compile and upload modified versions of the sketch.
Text editor powered by tinymce.