In this post I will explain how you can expend the number of IO of your Arduino via Maxim 1wire DS24O8.
The DS2408 is an 8-channel, programmable I/O 1-Wire® chip. PIO outputs are configured as open-drain and provide an on resistance of 100Ω max. A robust PIO channel-access communication protocol ensures that PIO output-setting changes occur error-free. A data-valid strobe output can be used to latch PIO logic states into external circuitry such as a D/A converter (DAC) or microcontroller data bus.
Price: less than $30 (Amazon)
Price: around $10 (Amazon)
1Wire bus on Arduino
1-wire is a Dallas Semiconductor proprietary adressed serial protocol. This protocol based on a master (in our case the Arduino) communicating with several slave connected to the bus. The same wire is used to power and to communicate with all slaves. Communication operating in parasitic power signal.
Wiring the bus on arduino
Add DS2408 to the 1wire bus
DS2408 pinout is the following:
Wiring DS2408 to 1wire bus
- 5V from 1wire bus goes to Vcc(Pin3)
- GND from 1wire bus goes to GND(Pin5)
- Data from 1wire bus goes to I/O(Pin4)
- RSTZ also goes to 5V – no reset on this configuration.
Code – Detected DS2408
This sample counts and list DS2408 devices on the bus. This code uses the DS2408 library available here: https://github.com/queezythegreat/arduino-ds2408
And the output is:
Count!! Found 1 devices. 1. [29 AC 82 E 0 0 0 5F]
Use the DS2408 PIO
DS2408 has 8 PIO (from P0 to P7). Each PIO is opendrain and can be use as output or as input. No configuration is needed to use PIO as output or as input.
- to use pin as output, write value in PIO register
- to use pin as input, simply read value.
For this example, I choose to make a really simple program: When you push the switch the led turn on:
Add more IO
You can connect as many DS2408 as you want to the 1wire bus to expand IO to the infinite.
DS2408 package is 16-Pin SO, 150 mil. To use it on a breadboard you have to adapt it to DIP. you can buy an adapter or make your own.