Here's the code to control an ADG728 using an Arduino Duemilanove. The ADG728 is an 8 channel matrix switch that expands the number of inputs that the Arduino Duemilanove can handle. This allows for future expansion of inputs beyond the 6 analog inputs allowed by the Duemilanove.
// I2C Analog Matrix Switch
// by Jake Staub
// Controls one ADG728 8 channel Analog Matrix Switch via I2C/TWI
//
// Device address 10011(AD1)(AD0) from data sheet
// AD1 AD0 Device Addressed
// 0 0 U1
// 0 1 U2
// 1 0 U3
// 1 1 U4
// Input shift register (S8)(S7)(S6)(S5)(S4)(S3)(S2)(S1)
// 0 0 0 0 0 0 0 1 0x01 S1
// 0 0 0 0 0 0 1 0 0x02 S2
// 0 0 0 0 0 1 0 0 0x04 S3
// 0 0 0 0 1 0 0 0 0x08 S4
// 0 0 0 1 0 0 0 0 0x10 S5
// 0 0 1 0 0 0 0 0 0x20 S6
// 0 1 0 0 0 0 0 0 0x40 S7
// 1 0 0 0 0 0 0 0 0x80 S8
// Created 2 March 2009
// Arduino analog input 4 - I2C SDA
// Arduino analog input 5 - I2C SCL
#include Wire.h Note: Place carrets around Wire.h to pull Wire library into program.
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}
void loop()
{
Wire.beginTransmission(0x4c); // transmit to device U1 (0x4c or hex for 01001100)
// device address is specified in datasheet,
// up to three more devices could be used; U2, U3, U4 (addresses above)
Wire.send(0x01); // sends register byte for S1 (0x01 or hex for 00000001)
Wire.endTransmission(); // stop transmitting
}






