This might be an old method, but it seems to work, from Adafruit-Trinket-USB repo's README:
Arduino libraries allowing Trinket to act as USB devices
NOTE: This folder contains multiple libraries. Each library must be installed individually. Simply installing the master folder won't work. Move each library folder out of the master after you unzip into your libraries folder.
To this end, I did the following:
- Downloaded a ZIP of the repo.
- Extracted it.
- Recompressed the
TrinketHidCombo
folder into its own ZIP. - Went into Arduino IDE's menu:
Sketch
=>Include Library
=>Add .ZIP Library...
- Chose the
TrinketHidCombo.zip
file. - The middle status line of the Arduino IDE reported:
Library added to your libraries. Check "Include library" menu
. - I was then able to open this example (specifically
code.ino
) and "Verify
" it. It gave this warning, but still seemed to compile:Note that the "library" has been placed inIn file included from /Users/anton/Documents/Arduino/libraries/TrinketHidCombo/usbdrvasm_includer.S:24:0: /Users/anton/Documents/Arduino/libraries/TrinketHidCombo/usbdrv/usbdrvasm.S:17:0: warning: "__SFR_OFFSET" redefined #define __SFR_OFFSET 0 /* used by avr-libc's register definitions */ In file included from /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/io.h:99:0, from /Users/anton/Documents/Arduino/libraries/TrinketHidCombo/cmdline_defs.h:26, from /Users/anton/Documents/Arduino/libraries/TrinketHidCombo/usbdrvasm_includer.S:22: /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/sfr_defs.h:141:0: note: this is the location of the previous definition # define __SFR_OFFSET 0x20 Sketch uses 5448 bytes (90%) of program storage space. Maximum is 6012 bytes. Global variables use 123 bytes of dynamic memory.
~/Documents/Arduino/libraries/TrinketHidCombo
, and note also that most of the available program space has been used. - I don't know if it matters, but I didn't then do
Sketch
=>Include Library
=>TrinketHidCombo
-- it seemed to work without doing so. When I actually tried selecting that option, it just added all the.h
files (I think) to my Sketch's code, that it could find in the library:This made no difference to the output of the compilation.#include <TrinketHidComboC.h> #include <cmdline_defs.h> #include <TrinketHidCombo.h> #include <usbconfig.h>
- I'm not sure if the warning shown above matters. Discussion about it here and here -- evidently it doesn't matter. "SFR" stands for "Special Function Register". Lots more discussion here but probably not overly relevant. Also this.
Official Arduino guides on: installing libraries.
TrinketHidCombo
is likeTrinketKeyboard
, but can do both keyboard and mouse HID commands in the same library?
- Is it worth learning more about PlatformIO? Is it an Arduino-compatible dev environment that works inside VSCode?
- Try
TrinketKeyboard
. - Compare (inc. size and capabilities) with
TrinketHidCombo
. - Try getting/setting keyboard status LEDs.
- Try various USB HID commands/modes.