User Input Devices

Here is a brief survey of some common user input options for small embedded devices. Many are available on small breakout boards and most have links to mbed code examples in the cookbook or components pages. The is also a wiki page on common user output devices.

Pushbuttons or Switches

C&K tactile switch (pushbutton) and an 8 position CTS DIP switch

SPST (Single Pole Single Throw - 2-pin) pushbuttons and switches are the most commonly used option for small devices and also are the lowest cost option. Pull up resistors (internal or external) must be used to connect then to a digital logic input. When the number of times the button is hit is critical, they also need to be debounced. Since they are mechanical they can wear out over time. Once things get complex and several pushbuttons are needed, some other devices might be easier for users. DIP switches can be used to setup configuration options that rarely change. Early PCs had DIP switches, but many users did not read instructions and had problems setting the DIP switches on cards. It led to a large number of product returns and help line calls from users. PCs now do this configuration automatically in software. For more information and code examples using pull ups, switch debouncing, and interrupts, see this pushbutton cookbook page.

Skyscan Digital Travel Clock

Digital clocks use several pushbuttons, but can be confusing to many users when setting the clock or alarm without the instructions.


pot LP tp
Sparkfun 10K Potentiometer, Sparkfun 10K Linear Potentiometer and breadboard friendly mini trimpot

Potentiometers or variable resistors can be hooked up as a voltage divider and used as an analog input. They do not rotate more than about 300 degrees. Linear potentiometers slide back and forth. Just hookup the wiper contact (usually the center pin) to an analog input and the other two pins to power (gnd and Vout). Use the mbed AnalogIn API.


The mbed application shield component page has an example for the two sky blue mini 10K potentiometers seen on the board above. There is also a potentiometer component page.

Traditionally, potentiometers have been used for almost a century in audio volume controls on radios. Some volume controls use a potentiometer with a logarithmic scaling or "taper". Linear or slider style potentiometers are also found on most audio mixers.


Sparkfun Analog Joystick Breakout and Sparkfun 5-way Tactile Switch Joystick (Digital)

Joysticks (or navigation switches) are widely used in video games and most users have an intuitive feel of how to use them. They send back X and Y movement information. Some Joysticks use two potentiometers to generate two X and Y analog outputs and some just contain four pushbuttons with a digital interface. Most joysticks have a center pushbutton. For more information, see this components page for the Grove joystick or Sparkfun Joystick. The mbed application board has example code for the digital tactile switch style joystick found on the board. Adafruit also has a tactile switch joystick with through hole PCB leads that will fit directly in a breadboard with a little lead bending and a mini thumb analog joystick. More information and mbed code examples for navigation switches is available.

The Sony PS2 controller uses a joystick similar to the one on the Sparkfun board.

The first electronic joystick was patented in 1926 and used for RC aircraft at the US NRL

Rotary Pulse Generators

Sparkfun Rotary Pulse Generator

Rotary Pulse Generators (RPGs) or rotary encoders have a continuously rotating knob that generates two digital pulse outputs. The pulses indicate the direction of motion and the amount of rotation. Usually the knob can also be pushed in for a select or enter feature. They are useful when used with an LCD display. Rotating the knob can move through 1D menus on the LCD and pushing the knob selects an item. RPGs can be found on many test instruments such as logic analyzers and oscilloscopes. For more information, see this RPG cookbook page and another project that adds LCD menus for the RPG.

The Stylish Nest IoT Thermostat uses only an (optical) RPG for input.


Sparkfun 12 key numeric keypad

Small keypads typically contain a SPST switch for each key. Key switches are connected in a 2D matrix with a switch connecting each row to each column. Software-based keyboard scanning techniques are typically used to encode the keypads so that fewer GPIO bits are required. Software scans through rows, forcing only one row active at a time and then reads all of the columns to detect a closed switch. For more information, see this keypad cookbook page.

The Classic Telephone numeric keypad was introduced in the 1960s by Bell Labs.

Touch Switches

Left: Sparkfun I2C Touch Keypad and Right: Touch button
Touch switches measure the change in capacitance that occurs when a finger is placed on or near a metallic electrode. Since they have no moving parts, they can be more durable than pushbuttons or switches. For more information on the keypad, see this touch keypad cookbook page. The single touch button code example connects to a digital input using the mbed DigitalIn API. It also provides user feedback with an LED when hit. Additional options can be found in the touch sensor components page.

Early Apple iPods used touch switches for the click wheel user interface

PC Keyboards or Mice

Sparkfun's USB A breakout can be used to connect PC keyboards or mice. Add two 15k resistors tied to GND on D+ and D-.

PC Keyboards or Mice can be used, but are too large for many small and mobile embedded devices. Either PS/2 or USB interfaces can be used. To make mbed act like a USB keyboard and mouse for a PC, see this USB handbook page. There are also PS/2 examples in the cookbook. PS/2 devices would be easier to use with mbed since they have a simpler interface. Sparkfun made a PS/2 connector breakout board that would allow a keyboard or mouse to be interfaced using a breadboard, if you could still find one. Old PS2 hardware is getting more difficult to find since PCs all moved to USB several years ago. There are new beta versions of USB host drivers for a USB Keyboard and mouse that can be used and they require the RTOS. Keyboards send scan codes that are somewhat related to the key's switch location in the matrix used in the encoder (i.e., not ASCII). Mice send periodic three-byte data movement and button status packets. If your mbed platform does not include a USB Type A connector, a breakout board like the one above will be required for USB devices. A powered USB hub will likely be needed to provide enough 5V power, when more than one USB device is connected to mbed.

Older Style PS/2 keyboard

The mouse was developed in the 1960s at Stanford Research Institute.


Sparkfun's Blackberry Trackball Breakout

Trackballs are very similar to mice. The user rolls a small ball to point. The small trackball used in the Blackberry phone has an mbed hello world code example. The do not require a large surface area (unlike a mouse) and can be attached to a case or enclosure.

Touch Screens

A small 2.4 inch touch screen from 4DSystems

Touch screens similar to those used in smart phones and tablets are available on many larger LCD screens. They are handy, but cost more than some other options and a larger LCD may be needed for complex touch inputs. Touch screens can be resistive or capacitive. Capacitive often works better, but also tends to cost more. Many LCDs with touch will require an mbed platform with a shield style header connector or additional cabling will be needed to connect to a breadboard. For more information, see the touchscreen components page.

The 1994 IBM Simon was the first touch screen smartphone


Microphones can be used to detect and sample audio input. They typically provide an analog output signal that is connected to one of a microprocessor’s Analog to Digital converter inputs. The voltage levels are typically too low to use directly from the microphone output (i.e., too few A/D bits would change to provide accurate readings), so they are amplified prior to the microprocessors A/D converter input. In the case of PCs, a special purpose audio I/O chip is used that contains an A/D, D/A, level control, and analog mixer circuits. A gain of 25 to 100 is typical for these amplifier circuits and special purpose microphone amplifier ICs such as the MAX9814 are even available with Automatic Gain Control (AGC) that helps when audio levels can vary a lot. Two popular options for microphones are electret and the newer smaller SOW2430 MEMs microphone with a built-in amplifier as seen in the breakout boards below. The electret breakout board also contains the microphone amplifier IC on the back side of the board.

Adafruit MEMS Microphone Breakout

Adafruit Electret Microphone Amplifier with MAX9814 Auto Gain Control

The first carbon microphone was invented in 1876

Speech Recognition

The Easy VR module has a microphone, speaker, and processor with firmware for speech recognition

Small speech recognition chips can be used to detect a few voice commands. More advanced speech recognition with a large vocabulary similar to that found in smartphones or tablets requires a network connection to a cloud-based server that runs a web speech recognition API. Google and Microsoft devices require a license key and new devices must pay for a license fee to use these services. For more information on the standalone IC option, see this EasyVR cookbook page.

Recent Furby toys have a speech recognition chip


Amazon’s Echo or the new lower cost Dot bring voice recognition to a box with speakers, WiFi, and Bluetooth to stream music and control home devices.

Apple is also working on a similar device. Both Amazon Echo/Dot and Google Home have an SDK for developers. An example demo using the Amazon Echo/Dot with mbed is available.

The new Google Home is another similar device. Both devices contain an array of microphones to enhance far-field speech recognition.

Gesture Sensors

Sparkfun Gesture Sensor breakout board

Phones and Tablets often use a gesture sensor which detects a few simple hand and finger movements near the device. There is a code example in the cookbook for an older more expensive gesture sensor and a code example for the new Sparkfun APDS 9960 Gesture Sensor breakout.

The IC on the Sparkfun board is also used in the Samsung Galaxy 5.

The new USB Leap motion controller can even track complex finger gestures on both hands.

IR and RF remotes

/media/uploads/4180_1/tvrem.jpg /media/uploads/4180_1/carfob.jpg

TV remotes use an Infrared LED and Car key fobs use RF

Many embedded devices use handheld IR and RF remote controls for a few basic functions at a very low bit rate. TVs and radios typically have Infrared (IR) remote controls. Most cars now have a radio frequency (RF) remote key fob. Wireless keyboards and mice use RF links at 27Mhz or 2.4Ghz. Key fobs, garage door openers, and some home automation systems use 315Mhz or 434Mhz. Since these devices are used in mass produced consumer products, these parts are widely available and relatively inexpensive. A getting started tutorial and mbed demo for IR and RF remotes can be found in the cookbook.

The first TV remote appeared in 1955 and was basically a spot flashlight. A motor flipped the tuner through the channels. Ultrasonic clicks were then used for many years. IR LEDs came in use 25 years later to improve reliability in changing lighting conditions.

Motion Sensors

SparkFun 9 Degrees of Freedom LSM9DS0 IMU

Low cost MEMs accelerometers, gyros, or new single chip IMUs that contain both along with a magnetometer can be used as motion sensors. The Wii Nunchuck uses a triple axis accelerometer to detect a user's hand motion. The Sony Playstation Move also uses a magnetometer. An accelerometer can detect tilt by sensing the gravity vector and is used in some tablets such as the Nexus 7 to switch from portrait to landscape mode. The Microsoft Kinect uses a scanning IR laser and a camera to generate 3D depth maps to detect user motion. Passive Infrared (PIR) motion sensors can be used to detect the presence of a user. The Nest IoT thermostat and the smoke alarm both use a PIR or motion sensor to activate the LCD and LED display functions when a user is detected. For more information, see the motion sensor components page and an early version of an mbed demo for the new LSM9DS0 single chip IMU.

The Gyration air mouse uses motion sensors and an RF link. It is handy for large presentations since the speaker can move anywhere in the room and a surface is not needed for the mouse.


A user’s geographic location could also perhaps be considered a passive user input. GPS receiver ICs use precision RF timing signals from several geosynchronous satellites to determine a user’s location. They do not work inside large buildings with steel or dense urban canyons. Most GPS ICs use a serial interface. If a device has network connectivity, IP addresses can be used to determine approximate locations by checking a large database on a server.

Adafruit GPS receiver breakout board

Sparkfun also has a new low cost GPS module.


Please log in to post comments.