Radio Buttons in the Real World

RadioButtonsRadio buttons were named after the physical buttons used on older car radios to select preset stations – when one of the buttons was pressed the other buttons would pop out, leaving the pressed button pushed-in as a visual reminder of the current choice.

These days radio  buttons are mainly found in graphic user interfaces. As an experiment, I wanted to create a physical user interface modeled on the concept, using LEDs and tact switches.

Radio buttons are groups of buttons that allow the selection of mutually exclusive choices whilst simultaneously showing which choice is currently selected. Therefore, at any time only one LED needs to be on to indicate the current choice. Importantly, selecting the same choice has no effect on the selection, so the tact switch at this location is temporarily redundant until a new choice is made. Similarly, the unlit LEDs are redundant until the associated choice is selected.

A simplistic implementation would have one input for the switch and one output for the LED, ending up using 2 I/O pins for each choice. From this basic implementation, the amount of I/O can be cut in half by doubling up each digital I/O as a both an input and an output, depending on whether the radio button is selected. A schematic for 4 choices is shown below.

RadioButton Schematic

When a button is not selected, the Arduino pin is set as INPUT_PULLUP, waiting for the tact switch to be pressed. For the currently selected choice, the pin is set to OUTPUT and HIGH, so that the LED is on. When a new choice is detected, the old selection is set to INPUT_PULLUP and the new one to OUTPUT and HIGH, and so on.

As only one LED is on at any time, only one resistor is needed for all the LEDs (180Ω  in the schematic). To prevent a dead short in case a user (re)selects the current choice, a 1kΩ resistor is inserted in the button circuit. The value for this resistor is not critical, but should be less than the value of the INPUT_PULLUP internal resistor (> 5kΩ) so that the button press is still detected.

RadioButton TactThe initial prototype was assembled on a breadboard, using separate switches and LEDs. The final version is implemented using an illuminated tactile switch to better emulate the true look of software radio buttons.

I also wrote an Arduino library, with example code, that can be used to manage the radio button group. This can be found with my other code libraries. A short video of the buttons and library in action can be viewed here.

There are undoubtedly many other methods that can be used to minimize the I/O requirements (such as using SPI with 595 and 165 ICs), but the ability to rapidly switch a pin from input to output is a capability that may come in handy for other applications.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s