"The Joystick library can only be used with a USB MCU" while using pro micro

I recently bought some what seem to be decent quality pro micro clones for a button box project. Windows detects the pro micro, and inside the IDE the board is detected on com 3 as a Leonardo. For some reason when I try to upload the joystick test sketch, I get an error message.

"#error The Joystick library can only be used with a USB MCU (e.g. Arduino Leonardo, Arduino Micro, etc.)."

What is causing IDE to see my board as a Leonardo, but not let me upload this sketch? I've tried selecting both leonardo and micro under tools>boards> but I keep getting the same message. Any ideas?

Link to the joystick library

I'm going to ask you to provide some additional information that might provide us with information to determine the cause of the problem.

Please do this:

  1. Select File > Preferences from the Arduino IDE's menus.
  2. Check the box next to "Show verbose output during: [] compilation".
  3. Click the OK button.
  4. Select Sketch > Verify/Compile from the Arduino IDE's menus.
  5. After the compilation fails you'll see a button on the right side of the orange bar in the Arduino IDE: Copy error messages. Click that button. This copies the full output to the clipboard.
  6. Open a forum reply here by clicking the Reply button.
  7. Click the </> icon on the post composer toolbar. This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  8. Press Ctrl+V. This will paste the compilation output into the code block.
  9. Move the cursor outside of the code tags before you add any additional text to your reply.
  10. Click the Reply button to post the output.

Here's the error message:

Arduino: 1.8.13 Hourly Build 2020/02/19 03:33 (Windows 10), Board: "Arduino Micro"

E:\Arduino\arduino-builder -dump-prefs -logger=machine -hardware E:\Arduino\hardware -hardware C:\Users\justi\AppData\Local\Arduino15\packages -tools E:\Arduino\tools-builder -tools E:\Arduino\hardware\tools\avr -tools C:\Users\justi\AppData\Local\Arduino15\packages -built-in-libraries E:\Arduino\libraries -libraries C:\Users\justi\Documents\Arduino\libraries -fqbn=arduino:avr:micro -vid-pid=0X2341_0X8037 -ide-version=10813 -build-path C:\Users\justi\AppData\Local\Temp\arduino_build_210816 -warnings=none -build-cache C:\Users\justi\AppData\Local\Temp\arduino_cache_258320 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avrdude.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avr-gcc.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -verbose C:\Users\justi\Documents\Arduino\libraries\ArduinoJoystickLibrary-master\examples\JoystickTest\JoystickTest.ino
E:\Arduino\arduino-builder -compile -logger=machine -hardware E:\Arduino\hardware -hardware C:\Users\justi\AppData\Local\Arduino15\packages -tools E:\Arduino\tools-builder -tools E:\Arduino\hardware\tools\avr -tools C:\Users\justi\AppData\Local\Arduino15\packages -built-in-libraries E:\Arduino\libraries -libraries C:\Users\justi\Documents\Arduino\libraries -fqbn=arduino:avr:micro -vid-pid=0X2341_0X8037 -ide-version=10813 -build-path C:\Users\justi\AppData\Local\Temp\arduino_build_210816 -warnings=none -build-cache C:\Users\justi\AppData\Local\Temp\arduino_cache_258320 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avrdude.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avr-gcc.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -verbose C:\Users\justi\Documents\Arduino\libraries\ArduinoJoystickLibrary-master\examples\JoystickTest\JoystickTest.ino
Using board 'micro' from platform in folder: C:\Users\justi\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Using core 'arduino' from platform in folder: C:\Users\justi\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Detecting libraries used...
"C:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8037 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Micro\"" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\micro" "C:\\Users\\justi\\AppData\\Local\\Temp\\arduino_build_210816\\sketch\\JoystickTest.ino.cpp" -o nul
Alternatives for Joystick.h: [ArduinoJoystickLibrary-master@2.0.7]
ResolveLibrary(Joystick.h)
  -> candidates: [ArduinoJoystickLibrary-master@2.0.7]
"C:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8037 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Micro\"" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\micro" "-IC:\\Users\\justi\\Documents\\Arduino\\libraries\\ArduinoJoystickLibrary-master\\src" "C:\\Users\\justi\\AppData\\Local\\Temp\\arduino_build_210816\\sketch\\JoystickTest.ino.cpp" -o nul
Error while detecting libraries included by C:\Users\justi\AppData\Local\Temp\arduino_build_210816\sketch\JoystickTest.ino.cpp
"C:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8037 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Micro\"" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\micro" "-IC:\\Users\\justi\\Documents\\Arduino\\libraries\\ArduinoJoystickLibrary-master\\src" "C:\\Users\\justi\\Documents\\Arduino\\libraries\\ArduinoJoystickLibrary-master\\src\\DynamicHID\\DynamicHID.cpp" -o nul
"C:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8037 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Micro\"" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\micro" "-IC:\\Users\\justi\\Documents\\Arduino\\libraries\\ArduinoJoystickLibrary-master\\src" "C:\\Users\\justi\\Documents\\Arduino\\libraries\\ArduinoJoystickLibrary-master\\src\\Joystick.cpp" -o nul
Error while detecting libraries included by C:\Users\justi\Documents\Arduino\libraries\ArduinoJoystickLibrary-master\src\Joystick.cpp
Generating function prototypes...
"C:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8037 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Micro\"" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\micro" "-IC:\\Users\\justi\\Documents\\Arduino\\libraries\\ArduinoJoystickLibrary-master\\src" "C:\\Users\\justi\\AppData\\Local\\Temp\\arduino_build_210816\\sketch\\JoystickTest.ino.cpp" -o "C:\\Users\\justi\\AppData\\Local\\Temp\\arduino_build_210816\\preproc\\ctags_target_for_gcc_minus_e.cpp"
In file included from C:\Users\justi\Documents\Arduino\libraries\ArduinoJoystickLibrary-master\examples\JoystickTest\JoystickTest.ino:13:0:

C:\Users\justi\Documents\Arduino\libraries\ArduinoJoystickLibrary-master\src/Joystick.h:32:2: error: #error The Joystick library can only be used with a USB MCU (e.g. Arduino Leonardo, Arduino Micro, etc.).

 #error The Joystick library can only be used with a USB MCU (e.g. Arduino Leonardo, Arduino Micro, etc.).

  ^~~~~

Using library ArduinoJoystickLibrary-master at version 2.0.7 in folder: C:\Users\justi\Documents\Arduino\libraries\ArduinoJoystickLibrary-master 
exit status 1
Error compiling for board Arduino Micro.

It is strange. I notice you are using a very old hourly build of the Arduino IDE. I don't have any specific idea of why that would be a problem, but the hourly build might be anything. Please try it again using Arduino IDE 1.8.16:

Other than that, everything looks just the same as my system, but when I compile the sketch on my system there is no error.

Nope still not working. It's weird because the board has the 32u4 chip and seems to be reputable. I guess I'll try ordering a different brand and see if that changes anything.

This has nothing to do with the physical board. The compilation is failing on your computer. That would happen even if you didn't own a Micro and didn't have anything at all connected to your computer.

You need to find out what is wrong with the software installed on your computer.

What happens if you compile this minimal test sketch?

#if !defined(USBCON)
#error USBCON is not defined!
#endif
void setup() {}
void loop() {}

I get this

Arduino: 1.8.16 Hourly Build 2020/02/19 03:33 (Windows 10), Board: "Arduino Micro"

E:\Arduino\arduino-builder -dump-prefs -logger=machine -hardware E:\Arduino\hardware -hardware C:\Users\justi\AppData\Local\Arduino15\packages -tools E:\Arduino\tools-builder -tools E:\Arduino\hardware\tools\avr -tools C:\Users\justi\AppData\Local\Arduino15\packages -built-in-libraries E:\Arduino\libraries -libraries C:\Users\justi\Documents\Arduino\libraries -fqbn=arduino:avr:micro -vid-pid=2341_8036 -ide-version=10816 -build-path C:\Users\justi\AppData\Local\Temp\arduino_build_106000 -warnings=none -build-cache C:\Users\justi\AppData\Local\Temp\arduino_cache_611869 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.arduinoOTA.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avrdude.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\justi\Documents\Arduino\sketch_sep19a\sketch_sep19a.ino

E:\Arduino\arduino-builder -compile -logger=machine -hardware E:\Arduino\hardware -hardware C:\Users\justi\AppData\Local\Arduino15\packages -tools E:\Arduino\tools-builder -tools E:\Arduino\hardware\tools\avr -tools C:\Users\justi\AppData\Local\Arduino15\packages -built-in-libraries E:\Arduino\libraries -libraries C:\Users\justi\Documents\Arduino\libraries -fqbn=arduino:avr:micro -vid-pid=2341_8036 -ide-version=10816 -build-path C:\Users\justi\AppData\Local\Temp\arduino_build_106000 -warnings=none -build-cache C:\Users\justi\AppData\Local\Temp\arduino_cache_611869 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.arduinoOTA.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avrdude.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\justi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\justi\Documents\Arduino\sketch_sep19a\sketch_sep19a.ino

Using board 'micro' from platform in folder: C:\Users\justi\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3

Using core 'arduino' from platform in folder: C:\Users\justi\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3

Detecting libraries used...

"C:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -DF_CPU=16000000L -DARDUINO=10816 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8037 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Micro\"" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\micro" "C:\\Users\\justi\\AppData\\Local\\Temp\\arduino_build_106000\\sketch\\sketch_sep19a.ino.cpp" -o nul

Error while detecting libraries included by C:\Users\justi\AppData\Local\Temp\arduino_build_106000\sketch\sketch_sep19a.ino.cpp

Generating function prototypes...

"C:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -DF_CPU=16000000L -DARDUINO=10816 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8037 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Micro\"" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\micro" "C:\\Users\\justi\\AppData\\Local\\Temp\\arduino_build_106000\\sketch\\sketch_sep19a.ino.cpp" -o "C:\\Users\\justi\\AppData\\Local\\Temp\\arduino_build_106000\\preproc\\ctags_target_for_gcc_minus_e.cpp"

sketch_sep19a:2:2: error: #error USBCON is not defined!

 #error USBCON is not defined!

  ^~~~~

exit status 1

#error USBCON is not defined!


For some reason there is no -mmcu=atmega32u4 option here.

Generating function prototypes...

"C:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" 
	-c -g -Os -w -std=gnu++11 
	-fpermissive -fno-exceptions -ffunction-sections 
	-fdata-sections -fno-threadsafe-statics 
	-Wno-error=narrowing -flto -w -x c++ -E -CC 
	-DF_CPU=16000000L -DARDUINO=10816 
	-DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR 
	-DUSB_VID=0x2341 -DUSB_PID=0x8037 
	"-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Micro\""
	"-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" 
	"-IC:\\Users\\justi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\micro" 
	"C:\\Users\\justi\\AppData\\Local\\Temp\\arduino_build_106000\\sketch\\sketch_sep19a.ino.cpp" 
	-o "C:\\Users\\justi\\AppData\\Local\\Temp\\arduino_build_106000\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Sorry I'm not sure what to do with that. Are you saying that the board itself isn't listed as having the 32u4 chip when talking to IDE?

One of the compilation commands is missing an essential flag that tells the compiler that you are compiling for the ATmega32U4 microcontroller.

Please try this:

  1. Select Tools > Board > Boards Manager from the Arduino IDE's menus.
  2. Wait for the updates to finish.
  3. Scroll down through the list of boards platforms until you see "Arduino AVR Boards by Arduino" Click on it.
  4. Click the Remove button.
  5. A confirmation dialog will now open. Click the Yes button.
  6. Wait for the removal to finish.
  7. Click the Close button.

Now try compiling the sketch again.

The instructions above will cause the IDE to use the version of the "Arduino AVR Boards" platform that comes bundled with the Arduino IDE installation rather than the previous installation you had installed via Boards Manager. My thought is that it's possible the Boards Manager installation has been modified.

still nothing

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.