This project is to use an Arduino Uno R3 board to support rotary encoders in DIY button boxes.
These boxes are popular in the racing 🚙, flight
If you're just using buttons and toggle switches, you can build a simpler box using an arcade- style USB button board (also available on Amazon or AliExpress).
Rotary encoders have two outputs: outputA
and outputB
. By detecting the phase shift as the
knob is rotated, you can tell both where the knob is at on the dial and which way it is being
turned. That's what this project sets up your micro-controller to do. By default it maps outputA
and outputB
to Arduino pins 6
and 7
respectively.
The Uno has a total of fourteen I/O pins. If you have more rotary encoders (as in the above image), simply adjust the code accordingly. You can either use an arcade board or add code to handle buttons / toggle switches.
There are several software packages that allow you to map the controls in your button box to whatever sim game you're interested in. Searching the sim forums on Reddit will give you an idea of the strengths and weaknesses of different mappers, and what works with what game.
Happy simming!
This has been tested using Arduino Uno R3 board and Arduino IDE v1.6.
To use this code with your Arduino Uno micro-controller:
-
Fetch the official Arduino IDE: http://arduino.cc/en/main/software
-
Untar the file to somewhere suitable e.g.
/home/user/arduino_ide
-
Install the following dependencies:
avr-libc avrdude binutils-avr gcc-avr
You can also re-use the binaries shipped with the Arduino IDE. To do so, set your PATH environment variable accordingly.
-
Checkout this repository:
git clone git://github.com/webstackdev/button-box.git
-
Edit the
Makefile
file to suit your environment. There are two variables that you will need to edit:ARDUINO_HOME
: the path where you untarred the IDE in step number one.SERIAL
: the path where your arduino listens on. If you don't know which one, try plugging and unplugging the board and see what pseudofile in/dev/
is added.
-
Edit
main.cpp
file if are adding rotary encoders, buttons, switches, or changing the input pin mappings. -
make
thenmake push
.
The Makefile supports three commands:
all
: build and link the main binarypush
: push the binary to the boardclean
: remove the intermediary files