Arduino Pills – Setting up IDE and Libraries

Another quick pill about Arduino, this is about setting up the IDE and manage libraries.

Arduino IDE (Integrated Development Environment) is not as advanced as other solutions but it’s quite light and easy to use. It can be found here.

Once installed, you might want to change the default sketchbook location by opening FilePreferences.
Now download, save and open a source file, for instance the one we are using in the Step by Step guide (it can be found here on AM-STUDIO’s GitHub) then compile it. You will get a number of errors, let’s review them.

Libraries

Libraries are, simply put, a collection of methods and functions that tell the board how to perform certain tasks. The default package contains only a little fraction of the available libraries, not to mention the fact that you can write your own. The “Joystick” library, that our project requires, does not come by default so we have to install it in a specific location. That location is the “libraries” subfolder of the aforementioned default sketchbook location.

arduino-pills-2-libraries
“libraries” subfolder location

Let’s download the Joystick library from GitHub and install it.
Careful though to respect the order of the subfolders: the ZIP file comes with a folder called “ArduinoJoystickLibrary-master”; if you copy this folder in your libraries your project won’t compile. So:

  1. open the ZIP file;
  2. open the “ArduinoJoystickLibrary-master” folder;
  3. copy the “Joystick” folder;
  4. Paste it into your Arduino “libraries” folder.

A couple of friends had to install the “keypad” folder as well. This library can be installed in a different and faster way. Go to SketchInclude LibraryManage Libraries and look for “keypad”. Scroll until you find the library I have selected in the following screenshot and install it.

arduino-pills-2-keypad-library
Installation of the Keypad library

Lord of the boards

Last step is selecting the correct board and the relative port. Depending on which board you have bought, select either “Arduino Leonardo” or “Arduino/Genuino Micro” from the ToolsBoard: “xyz”. Then, in a similar way, select the correct port from the “Port” menu: ToolsPort: “xyz”.
Both entries report the last option selected.

Quick troubleshooting

Always try to isolate the issue. Since we are using a source code that definitely work you should fairly easily found the issue, at this stage is either a library problem or missing or a connectivy issue. The IDE suggests you where the problem is. The following, for instance, is caused by the selection of an incorrect Port.

arduino-pills-2-error
Arduino uploading error: wrong port selected

Advertisements

Arduino Pills – Change USB HID names

When multiple control boxes are connected they all come with the same name. In theory that’s not a big issue but I have noticed that DCS sometimes messes up. There must be a way to fix this situation, isn’t it?

A-firm, the solutions is quite simple: we just need to change a couple lines in the boards.txt file, then recompile and write the code.

My Kingdom for a Board!

boards.txt is a sneaky file though because it’s located in multiple folders. The one we are aiming for (and it should work for you as well) is located in AppData.

As of now, the path is:
C:\Users\USERNAME\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21
If the path doesn’t exist start from AppData and walk your wait down to boards.txt.

arduino-pills-vid_pid
boards.txt Path

Open boards.txt and locate this three fields:

leonardo.build.vid
leonardo.build.pid
leonardo.build.usb_product

These are the values we want to change. These, for instance, are mine:

arduino-pills-1-boardstxt
vid, pid and product from boards.txt

If you are using a Genuino Micro instead of Arduino Leonardo (it’s still based on the ATmega32u4), the values you need to change are different. These are from my Radio box, for instance:

micro.build.vid=0x1212
micro.build.pid=0x3434
micro.build.usb_product="K Radio Panel"

If you are wondering where I got my VID and PID values well, I’ve blatantly invented them. IIRC for commercial applications you should buy them; I guess they work as the MAC address. It’s not a problem for us since we are working on simple, personal, project.