Arduino electronics hardware software

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.

8 replies on “Radio Buttons in the Real World”

This looks great. I’m really new to arduino and would like to use this in my project.

I am making a controller pedal, there are 10 (radio) buttons and 10 leds. I’m using a mega arduino and this seems an easier way than initially I was looking at doing it.

When a button is pressed I want to beable to send a midi command.

I can’t see in the example how I would implement this.

Any help would be great.


if ((sel = != NO_SELECT)

As soon as the selection is not NO_SELECT, then the code has returned the index of the radiobutton. Instead of the print() above, send the MIDI message for that switch.

Liked by 1 person

Isn’t that the point? If each button has a different index, then it is up to your code to send the right message for each button.


In principle no different as long as the relay can be driven from the current available at the output pin. If not, you will need a switching transistor to switch a higher current through the relay coil, controlled by the output signal.

Liked by 1 person

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