Digital I/O is useful in implementing many external sensors. Such things as magnetic door switches, water level switch, motion sensors, panic buttons, and macro select switches, all make good digital inputs. A digital output can control a roof vent fan, illuminate LED indicators, control the furnace (HVAC), disconnect the telephone ringer, or any other on/off type of application you can think of.

Digital I/O Primer

Fred Hansen

Digital I/O is useful in implementing many external sensors. Such things as magnetic door switches, water level switch, motion sensors, panic buttons, and macro select switches, all make good digital inputs. A digital output can control a roof vent fan, illuminate LED indicators, control the furnace (HVAC), disconnect the telephone ringer, or any other on/off type of application you can think of.

Fred Hansen 
Twin Lakes Home Automation

Fred Hansen has been involved in Home Automation for the last five years and has been working at Twin Lakes Home Automation for the last two. He earned his Bachelor's degree in Computer Science from Indiana University of Pennsylvania in 1982 and has been an avid electronics hobbyist for as long as he can remember.

In this issue we take a look at digital I/O. If you are interested in getting involved with electronics, this is certainly a good place to begin.  If you are an experienced electronics hobbyist, it is still worth some time to gain an understanding of how digital I/O works and what you can do with it.

So, just what is digital I/O? Basically, digital signals are signals that have just two states: on or off. These two states are represented by some signal, usually an electrical voltage level. In the nominal case, the voltages used to represent the two states are 0 volts for off (or logic false), and 5 volts for on (or logic true). In reality, the input trigger voltage (or Input Threshold - the level at which an input is considered to be true) is almost always lower than 5 volts and outputs are frequently represented by a switch (transistor or relay) rather than an actual logic high (5 volt) output.

Digital I/O is useful in implementing many external sensors. Such things as magnetic door switches, water level switch, motion sensors, panic buttons, and macro select switches, all make good digital inputs. A digital output can control a roof vent fan, illuminate LED indicators, control the furnace (HVAC), disconnect the telephone ringer, or any other on/off type of application you can think of. Adding I/O to your computer is a pretty straight forward task. The easiest way is to buy a board that either plugs into your computer's back plane (card slot), or uses one of the available external ports (serial, parallel, or USB). The important characteristics of an I/O board include its cost, the number of inputs and outputs, and the characteristics of the inputs and outputs.

Digital Inputs

Lets look at digital inputs first. As mentioned earlier, one of a digital inputs characteristics is its Input Threshold voltage. This is the lowest voltage which is considered "on" by the input. Any voltage level below that puts the input in an "off" state. Normally the input threshold is something below 5 volts. This is important to allow for voltage loss in wiring and differences in voltage supply regulation. Another related characteristic is the maximum input voltage. Many digital inputs are restricted to a maximum input of approximately 5 volts. If you expect input voltage levels higher than this you must reduce the signal's voltage using external circuitry before you apply them to the board. A more flexible I/O board may allow input signals between 0 and 40 volts. This range generally supports just about anything you are likely to want to attach. In addition to the maximum input voltage, some I/O boards allow AC as well as DC inputs. This can be very handy for home automation since many common signals in the home are AC (furnace, door bell, telephone, etc.).

Another characteristic of digital inputs is the amount of current they require to operate. Input current draw is normally about 10 milli-amps. Some hardware with very low current inputs require less than 10 micro-amps. This may be handy for applications where the electronics generating the input signal has very little current drive capability, but generally the higher current inputs (10 ma) are sufficient.  For generic switching applications (motion sensors, door sensors, etc.) this is not of any particular concern.

One last thing to look for is whether or not optical isolation is provided. An optically isolated input uses a photo-transistor or photo-diode to electrically isolate the input circuit from the rest of the board's electronics. This protects both the board and your computer from damage in the event that something inappropriate is connected to one of the inputs.  For example, if you inadvertently touched a 110 VAC line to one of the board's inputs, optical isolation would limit the damage to the destruction of the electronics associated with just that one input.  The rest of the inputs, the outputs and your computer would be spared the effects of the error. Without optical isolation, you could easily destroy the digital I/O board and the parallel port on your computer.  With luck, the damage would not extend to the rest of the system.


The characteristics of a digital output include it's ability to drive an external circuit (maximum output current), the output type (direct logic, transistor switch, relay, etc.) and its output voltage level or voltage range.  These characteristics combine to determine how easily external devices can be attached to the outputs of the board.  If the device you wish to attach is not compatible with the digital output then you must add some external electronics to bridge the requirements to the output's capabilities.

Ideally, the output current capability should be as high as possible. Unfortunately the trade off for high current is higher cost, so some sort of compromise is generally in order. The current drive capability is directly related to the type of output hardware used by the I/O board. The common output drivers are relay, transistor or direct logic driven.

Relay controlled outputs allow direct control of high current AC or DC loads. A typical relay might be rated 10 amps at 240 volts AC. This allows direct operation of such things as AC lighting, pumps, or motors. Relay controlled outputs are the most expensive, but allow control of just about anything.

Transistorized outputs utilize a transistor switch to complete a circuit to ground (when they are on) allowing about 150 milli-amps at 40 volts DC maximum. The voltage and current limitations are dependent upon the transistor used in the output's transistor driver. This type of output is fairly flexible and quite common. It is much cheaper than relays to implement and still allows switching of a fairly wide range of voltages.  The voltage and current limits are high enough so that you can attach a relay directly to the output, which means you can easily provide for controlling higher current or AC type loads.

Direct Logic I/O is often seen on very low cost hardware. The I/O is typically implemented using a large scale integration IC with the outputs and inputs directly connected to the IC's control pins. The primary advantage of this arrangement is cost. In addition, in most cases, each I/O port can be configured as either an input or output. The disadvantages are low output current drive and voltage, and lack of input protection. The outputs in this configuration will supply only a very small amount of current (typically about 2.5 ma.) at the IC's output voltage (2.4 volts is common). To drive a circuit that requires a higher voltage or current requires additional hardware.  The low current drive also means you cannot directly attach a relay.  A relay driver must be implemented before sufficient current or voltage is available for this task.  Note that some boards which use an integrated IC for I/O also provide transistor drivers or relays for output.  This would move the output characteristics to a different category.

Selecting an I/O Board

A number of criteria can be established in selecting an I/O board. The most important characteristic is whether or not it will work with your software and computer. You may have few (if any) choices. In this case it is still important to understand how the I/O is implemented so that you can take maximum advantage of it and avoid causing harm to the hardware.

If you do have a selection, choose a board with as much flexibility as possible for the cost. The more important criteria are output voltage and current. A 100 ma output at 5 volts is the minimum you should look for. Less than that and you can't safely directly connect a relay (a typical 5 volt relay takes about 75 ma to keep on). Direct Logic I/O should be avoided as too much external circuitry is required to use them.  The second criteria is the flexibility of the inputs. A voltage range of 4 to 20 volts lets you directly connect the vast majority of the things your likely to want to see. Obviously the wider the range the better. In the nice to have category are protected inputs (optical isolation) and AC / DC inputs. These are both very handy to have, but you can normally get along without them. If you are a beginner to electronics, however, you may find both of these features to be well worth the price.


Okay, so by now you've selected your ideal I/O board and have a thorough understanding of its capabilities. So lets look at a few examples!

A Digital Switch (Input)

A switch can be a magnetic door switch (to sense when a door is opened or closed), a physical toggle switch mounted on a panel somewhere, the relay output from your security system, or any other device which can make or break an electrical contact. Connecting a switch to a digital input is pretty easy.

In the diagram above, the digital input has a plus and a minus (ground) connection. When a positive voltage is applied to the plus terminal, the input is on. In this example the input voltage is obtained directly from the I/O board (from its regulated 5 volt supply). It is run to the switch and then back to the digital input. The ground is connected directly from VReg to the input's ground. When the switch is closed the circuit is complete and the digital input is at 5 volts. When the switch is open the voltage at the input is 0 and the digital input is off. You can substitute any switch for the one pictured. Even a motion sensor has two contacts for the input voltage and switched output (separate from its supply voltage).

An Indicator Light (Output)

As a simple output example, lets hook up a light to a digital output. For this example, we will use a transistor switch type digital output and a 5 volt DC light which draws 60 mA (Jameco part no. 141057).  We'll assume our output is rated up to 40 volts at 150 ma.  This makes this example really simple!

The output's plus terminal is nothing more than the board's regulated voltage supply. It is always at +5 volts and is not switched as part of the output's control. What is switched is the minus terminal. It is either at high impedance (open or off), or shorted to ground (closed or on). When it is shorted to ground, the circuit completes and the light goes on. Since the light is specified to operate at 5 volts and 60 mA, it can be directly attached to the output. If the light was a 12 volt bulb, you could use a 12 volt supply and attach it to the bulb's positive contact instead of the 5 volts we used in this example. The switched ground would still provide circuit completion and the light would go on.

If your I/O board has relay outputs, you would hook the light up as shown below. Output1 provides the connections for a SPDT relay. When the output is on, Cm (common) is connected to NO (normally open).  In this example, we substituted an LED and a 330 ohm resistor instead of an incandescent lamp (the resistor limits the amount of current that goes through the LED to about 15 mA).


Adding digital I/O to a system is easy and can add a whole new area of interest for the automation hobbyist. Door switches and motion detectors can be added by  simply running some wire and connecting them to some screw terminals.  Extensive knowledge of electronics is not required and the electronics generally operate on safe low voltage, low current wiring.  So what are you waiting for?

Comments (0)

This post does not have any comments. Be the first to leave a comment below.

Post A Comment

You must be logged in before you can post a comment. Login now.

Featured Product

Light sockets; Not just for lights anymore

Light sockets; Not just for lights anymore

Smart Bulbs are out there and they can do far more then just provide light. Speakers, projectors, wi-fi extenders and more. The standard light socket that is wired up and ready to go in nearly every home in North America is now providing an easy and affordable option for home owners and renters alike to enter into the world of the "Smart Home". Here is a look at some of the Smart Bulbs and Smart Lighting options out there, and this list is just the beginning. In this ongoing article we hope to continue to add to and grow this list, so stay tuned!