The MCP23017 can only output a digital high of the same voltage as VDD, which is capped at about 5 VDC (the exact value will be in the datasheet). However, I want to drive incandescent bulbs, which require about 12 VDC to illuminate them, so to drive these I will be making use of a number of the ULN2803:
The ULN2803A device is a 50 V, 500 mA Darlington transistor array. The device consists of eight NPN Darlington pairs that feature high-voltage outputs with common-cathode clamp diodes for switching inductive loads. The collector-current rating of each Darlington pair is 500 mA. The Darlington pairs may be connected in parallel for higher current capability.
Applications include relay drivers, hammer drivers, lamp drivers, display drivers (LED and gas discharge), line drivers, and logic buffers. The ULN2803A device has a 2.7 kΩ series base resistor for each Darlington pair for operation directly with TTL or 5-V CMOS devices.ULN2803 Datasheet
This 500 mA at up to 50 VDC compares with the MCP23017s 25 mA at 5 VDC.
In the image to the right, I show the two devices connected together with just channel GPA0 connected to 8B (Base), and a brushed DC motor is connected between 12V DC and 8C (collector).
Internal to the ULN2803 is a Darlington pair, a flyback diode and some support passives for each channel. the flyback diode protects the components when using the device with inductive loads, such as motors, coils, or relays.
In this instance, I am using the ULN2803 to switch on and off 12 x 12 VDC incandescent bulbs mounted in switches.
I am going to use two ULN2803s driven by one MCP23017. This will give me 16 channels. I could use low-side switching with a single N-FET of a Darlington pair made up of discrete components, however, this component makes the circuit much more straightforward.
The ULN2803 is very similar to the ULN2003 but has eight outputs rather than seven.
A quick warning!
When using different supply voltages, ensure that the ULN2803 or ULN2003’s common pin is taken to the supply of the load. If you don’t you may find the flyback diode allows enough current to flow, meaning that the load is turned on regardless of the input state.
In a future post, I will put this all together with an Arduino and a 3D-printed button enclosure.