[vc_row][vc_column width=”1/1″][vc_column_text]
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Features” tab_id=”1397390811-1-46″][vc_column_text]
- 16 bidirectional I/O ports. Default is input state.
- High-speed IIC interface (MCP23017): 100kHz, 400kHz, 1.7MHz
- Three hardware address pins allow up to eight devices on the bus
- Configurable interrupt output pin: can be configured for active-high (output), active-low (output) or open-drain (output)
- INTA and INTB can be configured to work independently or jointly
- Configurable interrupt sources: the interrupt changes according to the configured register defaults or pin level changes
- External reset input
- Low standby current: 1μA (max)
- Operating voltage:
- 1.8V to 5.5V (-40 ° C to +85 ° C)
- 2.7V to 5.5V (-40 ° C to +85 ° C)
- 4.5V to 5.5V (-40 ° C to +125 ° C)
[/vc_column_text][/vc_tab][vc_tab title=”Parts List” tab_id=”1397390811-2-32″][vc_column_text]
- 1 x [bigcommerce link=”/arduino-uno-compatible-usb-board-r3/” target=”_blank”]Arduino UNO[/bigcommerce]
- 1 x I/O Expander Shield
[/vc_column_text][/vc_tab][vc_tab title=”Code” tab_id=”1397392325545-2-1″][vc_column_text]
#include <Wire.h>
const byte mcp_address=0x20; // I2C Address of MCP23017 Chip
const byte GPIOA=0x12; // Register Address of Port A
const byte GPIOB=0x13; // Register Address of Port B
const byte IODIRA=0x00; // IODIRA register
const byte IODIRB=0x01; // IODIRB register
void setup()
{
//Send settings to MCP device
Wire.begin(); // join i2c bus (address optional for master)
Wire.beginTransmission(mcp_address);
Wire.write((byte)IODIRA); // IODIRA register
Wire.write((byte)0x03); // set GPIOA-0/GPIOA-1 to inputs
Wire.endTransmission();
}
void loop()
{
Wire.beginTransmission(mcp_address);
Wire.write((byte)GPIOA); // set MCP23017 memory pointer to GPIOB address
Wire.endTransmission();
Wire.requestFrom(0x20, 1); // request one byte of data from MCP20317
int inputs=Wire.read(); // store the incoming byte into "inputs"
if((inputs&0x01)==0)
{
Wire.beginTransmission(mcp_address);
Wire.write(GPIOA); // address bank A
Wire.write((byte)0x04); // value to send GPIOA-2 HIGH
Wire.endTransmission();
}
if((inputs&0x02)==0)
{
Wire.beginTransmission(mcp_address);
Wire.write(GPIOA); // address bank A
Wire.write((byte)0x08); // value to send GPIOA-3 HIGH
Wire.endTransmission();
}
else
{
Wire.beginTransmission(mcp_address);
Wire.write(GPIOA); // address bank A
Wire.write((byte)0x00); // value to send GPIOA LOW
Wire.endTransmission();
}
}
[/vc_column_text][/vc_tab][vc_tab title=”Testing” tab_id=”1397392385128-3-0″][vc_column_text]1. Install I/O Expander Shield onto Arduino UNO and power on,
2. Open Arduino IDE and copy the code, then upload to Arduino
3. Set all Jumpers to ON, press the button S1 and S2 respectively.
Press S1, L1 (RED) will turn on.
Press S2, L2 (GREEN) will turn on.
[/vc_column_text][/vc_tab][vc_tab title=”Schematics” tab_id=”1397392598006-4-2″][vc_column_text]io expander shield SCH[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]

August 26, 2014 at 1:02 am
Could you have a sample of code, perhaps a single pin of one of the banks acting as an output.