My First Microcontroller Prop

While I had previously dabbled in very basic light up props before, they were fairly basic: a pile of LEDs hand wired to a battery, resistor and switch with no actual logic or controller involved. My first prop to actually employ a microcontroller was built for my player character in the Cottington campaigns. The character, Johan, is in short a mad scientist with a bent for dreaming and the mind, and he has a variety of devices for measuring and influencing brain waves. The initial design concept was to actually make a simple but interactive representation of one of these devices, that would actually have a quick ‘synchronize with the recipients brain waves’ phase.

Final Device

A quick demonstration of the device

The eventual device was housed in a simple wooden box, small enough to be easy to carry around, but large enough to easily contain the electronic components. It has a gauge display with a rotating needle, four LED lights, two dials to adjust, and a switch to turn the device on and off.

One LED is simply to designate if the device is in the operational state, a second is used during the ‘synchronization’ phase. The final two are used for feedback during the ‘operational’ phase, one turning on for ‘high’ values displayed by the gauge, the other turning on for ‘low’ values displayed by the gauge.

On turning on the device enters a synchronization state, the two knobs must be adjusted (to randomly determined values), with feedback provided in terms of the rate of blinking on the yellow ‘sync’ light. Once achieved, it switches to ‘operational’ state.

The operational state is a slowly shifting gauge (all randomly driven), where passing certain thresholds turn on the red and blue leds.

Hardware

Here are the internals, paired with a view of my very sloppy wiring. The bottom left from this view is an Arduino Uno, which is the microcontroller that drives everything. The actual chip itself is fairly small, but the Uno board also provides power regulation (as I’ve learned in later projects, juggling battery voltages to the right levels for various components can be difficult, using the build in power regulation on an Uno is definitely simpler for learning), and the board provides a much more convenient USB connection for uploading code to the microcontroller, as well as providing easier to use headers for connecting wires to the system (as opposed to having to solder directly to a microchip). The Arduino can be programmed using a pared down subset of the C++, code uploaded via USB. There are a number of ‘pins’ as they are referred to, for connecting wires to. Certain pins can be simply used as digital inputs or outputs (there either is a signal, or is not), others can be used as analog inputs or outputs(the signal may have a strength, in this case voltage). There are some more advanced facets, where there are certain protocols which certain pins are required for. In this simpler device, I made use of two analog inputs (for the dials), one analog output (for the dial gauge), and four digital outputs (for the LEDs).

The top left is a tangle of wires, with a resistor hidden under liquid electrical tape that the various LED’s are wired to.

Example of a servo

The center of device houses a servo. While servos can be used to mean a few different things, in this case (and the most common use of the term), this refers to what is essentially an electrical motor that can turn through a limited range of motion, and you can control what position it is at by means of adjusting an analog input to the system. I will briefly note that these analog outputs from the Arduino to a Servo are not actually truly analog, and are in fact what is called ‘Pulse Width Modulation,’ basically switching between off and on very quickly where how much of the time it is on versus off being the actually varying value. But for simplicity’s sake, they can be thought of as analog outputs in this case. If you provide minimal voltage, the servo will move to one extreme, let us say clockwise. If you provide the maximum voltage, it will rotate to it’s other extreme in the counter-clockwise direction. Servos require three connections, a connection to positive voltage and ground to supply power in addition to the analog(PWM) input which is used to drive their position. While it is possible with a single small servo such as this to directly power it from the Arduino board itself, in general it is preferable to connect servos to other power sources, since the power regulator on an Arduino can only supply a limited amount of current.

Above the battery to the left, you can see the backs of the dials. The dials are actually potentiometers. Potentiometers are an implementation of what is known as a voltage divider. By arranging a circuit such that the current crosses one resistor, then has two routes to ground, one directly to ground, the other to ground but through a second resistor, then the voltage along the path that leads directly to ground will actually not be the full voltage that was applied to the beginning of the circuit. Instead, it will be that voltage time a ratio of the two resistance values. A potentiometer is a voltage divider, with one of the resistors being a variable resistor whose resistance is controlled by the knob. They have three connections, and by connecting the first to positive voltage, the last to ground, and the central connection to ground by way of an analog input connection (in this case, in the Arduino), you can then read the voltage of that final connection, and control and change said value by adjusting the knob.

Above the battery and to the left, there is a small black box, this is the backside of a push button switch for turning the device on and off.

Beneath the battery, the four black splotches with wires running to them are the four LEDs. LED’s are fairly simple to wire, they do have a direction to them. Typically, they will have one longer ‘leg’ which will be the side to which the positive voltage is applied. Due to LED’s having a maximum current they can withstand, you should generally have a resistor in series with a LED to limit the current.

Putting It All Together

The parts for this particular project were fairly simple. The microcontroller to serve as the ‘brains’ of the prop, two very simple inputs that are only used during the first phase, outputs are four LEDs which are simply on or off and a single analog(PWM) signal to control a servo.

The code for the Arduino and the wiring was thoroughly tested and developed before any attempt was made to build it into an actual prop. Taking the baby steps of using a Serial output system for debugging (basically, allowing the Arduino to print text to the computer while connected), I could make certain the potentiometers worked correctly and gave me the value range I was expecting, and similar basic testing.

The devil is always in the details, coming up with how to determine the blink timing for synchronization required quite a bit of iteration to find an approach that felt right, and it was basically a case of keep trying different approaches and testing.

There was some similar testing and revisions in adjusting the random patterns for the gauge needle positioning.

But, once all the testing was done with temporary wiring, all that was left was permanently affixing pieces to the actual prop housing, and making the wiring permanent.