Arduino I2C I/O Expander 14 Digital I/O and 4(8) Analog Input.   MCP23017 x 1 74HC4052 x 1 10Kohm x 2 (For pullup)

You can add 14 Digital I/O and 4(8) analog input easly for Arduino. ;-)

 

 

Arduino sample code:

 

#include <Wire.h> // I2C Lib.

 

void setup() {

 

Wire.begin(); //creates a Wire object

Serial.begin(9600);

// set I/O pins to outputs

Wire.beginTransmission(0x20); //begins talking to the slave device

Wire.write(0x00); //selects the IODIRA register

Wire.write(0x00); //this sets all port A pins to outputs

Wire.endTransmission(); //stops talking to device

Wire.beginTransmission(0x20);//begins talking again to slave device

Wire.write(0x01); //selects the IODIRB register

Wire.write(0x00); // sets all port B pins to outputs

Wire.endTransmission(); //ends communication with slave device

}

 

void loop()

{

Wire.beginTransmission(0x20); //starts talking to slave device

Wire.write(0x12); //selects the GPIOA pins

Wire.write(B00000001); // turns on pins 0 and 1 of GPIOA

Wire.endTransmission(); //ends communication with the device

 

Wire.beginTransmission(0x20); //starts talking to slave device

Wire.write(0x13); //selects the GPIOB pins

Wire.write(B00000001); //turns on pin 0 of GPIOA

Wire.endTransmission();//ends communication with the device

 

Serial.println(analogRead(0));

 

delay(500);

}