# Im new to Arduino but have a problem.....this could take some time

**URL:** <https://forum.arduino.cc/t/im-new-to-arduino-but-have-a-problem-this-could-take-some-time/939285>\
**Category:** General Discussion\
**Created:** [December 25, 2021, 2:38pm UTC](https://forum.arduino.cc/t/im-new-to-arduino-but-have-a-problem-this-could-take-some-time/939285 "2021-12-25T14:38:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![racdavies](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@racdavies](https://forum.arduino.cc/u/racdavies)\
**Post date:** [December 25, 2021, 2:38pm UTC](https://forum.arduino.cc/t/im-new-to-arduino-but-have-a-problem-this-could-take-some-time/939285/1 "2021-12-25T14:38:31Z")

</div>

Some time ago i purchased several button boxes for my sim rig which was great....or so i thought.

I have 3 boxes with 20+ buttons for specific driving games, 1 small box with 7 buttons to work with all my driving games and an 8 button box for just one game.

All boxes were all detected as game controllers and HID devices but with one major hurdle, they were all detected as Arduino Leonardo boards. After months of banging my head against a wall trying to find a way of renaming the boards i finally found a video on youtube which seemed to have a solution to my problem, i dont want to mention any names but Musinou springs to mind, eventually after editing the supplied board txt file i succeeded in naming one of my boxes, windows device manager detected my box with the changed name....thats great it thought so proceeded to use the same method on all 5 boxes with specific names, device manager listed all devices plugged in at the same time with the correct names and thats when i realized there was an issue...none of the boxes were detected as HID game controllers.

I decided to open up one of the boxes to find that the boxe actually contain a pro micro board which i found out was manufactured by Spark Fun, unfortunately i found out that the board was quite fragile and broke off the usb socket which upon a closer look did not look repairable so i found a replacment on ebay and ordered 1 from a UK seller, before the new board arrived i ordered 3 more just in case....same boards but from a different supplier.

With a few days off work over Christmas i decided to test the single purchase which was detected as a Spark fun board but not a HID device, out of curiosity i test one of the other 3 and that was a Leonardo HID device.

Now as far as i have been told....the same board was used in all my boxes so without opening the other boxes im assuming that they are all Spark Fun pro micro 5V ATmega32U4 Arduino compatible board.

The renaming method i used was(im assuming you are familiar with Musinou) to edit a board txt file by changing PID/Vid codes slightly and changing the build.usb\_product= to my required info in text editor and updating the boards with Arduino IDE. The boards file was also accompanied with a bootloader folder but Ive recently found a Spark fun board text file but it does not come with any files like the Musinou version.

I have also updated Arduino IDE to use the correct Sparkfun board and processor and the arduino as ISP (5V ATmega32U4) programmer but im yet to try it.

Before i start messing with Arduino IDE again can anyone give me a clue as to what might be stopping my devices from being detected as HID devices.

I know this was a long post but im new to this and this was the easiest way i could explain so any advice on this problem would be very much appreciated or even point me in the direction to the required files would be a great help.

Thanks for your time and Merry Christmas....stay safe.

---

<div class="post-metadata">

**Author:** ![dsmts](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dsmts](https://forum.arduino.cc/u/dsmts)\
**Post date:** [December 25, 2021, 8:15pm UTC](https://forum.arduino.cc/t/im-new-to-arduino-but-have-a-problem-this-could-take-some-time/939285/2 "2021-12-25T20:15:02Z")

</div>

They were being detected as HIDs because they were programmed to act as HIDs. When you used the IDE to change the vid and pid numbers, you uploaded new code to the board, erasing the chip and the program that was present.

As I understand it, making an HID with the Leonardo or the micro (pro) is easy because they have the ATMega32U4 processor with built-in USB support, and there are two HID libraries available (keyboard and mouse). The fact that those controllers contain the board, not just the chip, and that the developers used the arduino libraries and didn't remove the Leonardo name makes me think that they weren't experts, and the program probably used only standard arduino functions, not complex C++ code or assembler.

So the code is lost, but writing new code to get them working again shouldn't be too hard. There will be others who have used arduino to make their own controllers, if you google "arduino controller sim", or with the name of a specific game, you'll likely find info and code that you can use. Finding out which port each button is attached to is easy: use the example in Basics \> DigitalReadSerial to test every pin to see if it changes when you push the buttons (it's possible you have to use pinmode INPUT\_PULLUP).

You should probably change the title of this topic to something more descriptive (I don't know if that's possible, I'm new here) to get more response.

---

<div class="post-metadata">

**Author:** ![racdavies](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@racdavies](https://forum.arduino.cc/u/racdavies)\
**Post date:** [December 25, 2021, 9:28pm UTC](https://forum.arduino.cc/t/im-new-to-arduino-but-have-a-problem-this-could-take-some-time/939285/3 "2021-12-25T21:28:11Z")

</div>

Hi, thanks for the reply, when i purchased my first box i did ask the seller about renaming and he told me that all he had done was wire the buttons up...no software had been run to setup any thing.

One of the new replacement circuit boards i received and tested showed up in devices and printer named as Arduino Leonardo hid keyboard, renaming isnt so much the issue, the issue is which board text file i edit in the maze of folders in the Arduino install path....do i go with the arduino leonardo device path or spark fun, i have spark fun libraries installed but can not figure out which is the correct board text file to edit, also which is the correct programmer

---

<div class="post-metadata">

**Author:** ![dsmts](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dsmts](https://forum.arduino.cc/u/dsmts)\
**Post date:** [December 26, 2021, 10:29pm UTC](https://forum.arduino.cc/t/im-new-to-arduino-but-have-a-problem-this-could-take-some-time/939285/4 "2021-12-26T22:29:39Z")

</div>

If the guy who sold you the controllers only wired the buttons up, then he received the boards with the program on them (and with instructions telling him which buttons have to be connected to which ppins, since it's the program that determines that). Without a program, a microcontroller does nothing. The microcontrollers on arduino boards are programmed with boot loaders, small programs that make USB communication and programming via USB possible. But anything else requires a "main program".

That's the danger when you google for something like "change name HID device leonardo": most results will be pages from people who are programming arduino's. They will assume that people who follow their advice are doing the same thing, that they have written an HID program, and want to change the name. They won't warn readers that clicking "upload" will erase the program present on the board, because that's what an upload is meant to do. They also assume that when they write "upload", their readers know that they mean: "upload the HID program you have written".

The old IDE gave an error when you clicked upload without entering code first, but the new IDE automatically creates an empty setup() and loop() function, which is valid code, so you get no warning.

Your windows device manager still recognizes the controllers as usb devices because the boot loader is still present. But it doesn't recognize them as HIDs because the main program, that defined the HID device, is gone.

The only way I can think of to change the name, vid and pid of an existing device without erasing the program would be to download the contents of the flash memory (not always possible, the programmer may have disabled reading) or the EEPROM (depending on where the chip stores that data), use a hex editor to change the values (keeping the length of the name the same!), and writing that file back. AVR uses little-endian, so a vid= 2341 would be represented as 41 23 in memory.  
This topic has information on how to do that: [Possible to copy compiled code from one Arduino to another and have it function? - #14 by system](https://forum.arduino.cc/t/possible-to-copy-compiled-code-from-one-arduino-to-another-and-have-it-function/121243/14)

But that means risking another controller, if I were you I would first try to get the "broken" controllers working again. The joystick library ([GitHub - MHeironimus/ArduinoJoystickLibrary at version-2.0](https://github.com/MHeironimus/ArduinoJoystickLibrary/tree/version-2.0)) seems easy to use, try the gamepad example (I don't have a board with a 32u4 chip so I can't test it).

As for the board file: since they contain arduino micro boards but are recognized as leonardo boards, I would edit the micro and Leonardo sections in the boards.txt file, and select one of the two as board in the IDE, see what works; You don't have to select a programmer for a normal upload, that setting is only relevant when you choose "Upload using programmer" in the sketch menu.

---

<div class="post-metadata">

**Author:** ![racdavies](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@racdavies](https://forum.arduino.cc/u/racdavies)\
**Post date:** [December 26, 2021, 11:03pm UTC](https://forum.arduino.cc/t/im-new-to-arduino-but-have-a-problem-this-could-take-some-time/939285/5 "2021-12-26T23:03:15Z")

</div>

Hi, thanks for the great reply, i think i might contact the seller and see if there is anything he can do to help, i dont want to spend another £200+ to replace the boxes if he can just rewrite to the boards

---

<div class="post-metadata">

**Author:** ![racdavies](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@racdavies](https://forum.arduino.cc/u/racdavies)\
**Post date:** [December 27, 2021, 3:17pm UTC](https://forum.arduino.cc/t/im-new-to-arduino-but-have-a-problem-this-could-take-some-time/939285/6 "2021-12-27T15:17:08Z")

</div>

Hi, after further research i found a sketch for my boxes and managed to get one of my boxes detected again, also got the device renamed and detected in devices and printer as my renamed device both working arduino leonardo and sparkfun by editing the board txt usb line as before, unfortunatly the sparkfun board txt file only seems to show in the devices and printer with the new name, under device manager and asseto corso the box was detected as Spark Fun device.

Changing this line... promicro.build.usb\_product="SparkFun Pro Micro" to "ACC mainbox" worked, but changing this line promicro.name=SparkFun Pro Micro to promicro.name=ACC mainbox has rendered the devise as currently undectable as a coms device.

Using this board info as is with ARDUINO\_BUTTON\_BOXV2 sketch from AMSTUDIO worked perfect but only with a device name of SparkFun Pro Micro,

promicro.name=SparkFun Pro Micro

promicro.upload.tool=avrdude  
promicro.upload.protocol=avr109  
promicro.upload.maximum\_size=28672  
promicro.upload.maximum\_data\_size=2560  
promicro.upload.speed=57600  
promicro.upload.disable\_flushing=true  
promicro.upload.use\_1200bps\_touch=true  
promicro.upload.wait\_for\_upload\_port=true

promicro.bootloader.tool=avrdude  
promicro.bootloader.unlock\_bits=0x3F  
promicro.bootloader.lock\_bits=0x2F  
promicro.bootloader.low\_fuses=0xFF  
promicro.bootloader.high\_fuses=0xD8

promicro.build.board=AVR\_PROMICRO  
promicro.build.core=arduino:arduino  
promicro.build.variant=promicro  
promicro.build.mcu=atmega32u4  
promicro.build.usb\_product="SparkFun Pro Micro"  
promicro.build.vid=0x1b4f  
promicro.build.extra\_flags={build.usb\_flags}

---

<div class="post-metadata">

**Author:** ![dsmts](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dsmts](https://forum.arduino.cc/u/dsmts)\
**Post date:** [December 27, 2021, 4:09pm UTC](https://forum.arduino.cc/t/im-new-to-arduino-but-have-a-problem-this-could-take-some-time/939285/7 "2021-12-27T16:09:53Z")

</div>

I don't think I can help you with that. I thought the first name (promicro.name) was only used by the IDE. It's that name that will be shown in the list of boards in the tool menu. The last windows version I worked with was Windows 2000, so ...  
But it seems strange that changing the name would have that effect. Maybe windows remembers the old name and that's causing a conflict, dunno. I'm clueless, sorry.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 25, 2022, 4:10pm UTC](https://forum.arduino.cc/t/im-new-to-arduino-but-have-a-problem-this-could-take-some-time/939285/8 "2022-06-25T16:10:10Z")

</div>

Closed on June 25, 2022, 4:10pm UTC

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