1
// I2C Digital Potentiometer
2
// by Nicholas Zambetti <http://www.zambetti.com>
3
// and Shawn Bonkowski <http://people.interaction-ivrea.it/s.bonkowski/>
5
// Demonstrates use of the Wire library
6
// Controls AD5171 digital potentiometer via I2C/TWI
8
// Created 31 March 2006
10
// This example code is in the public domain.
12
// This example code is in the public domain.
19
Wire.begin(); // join i2c bus (address optional for master)
26
Wire.beginTransmission(44); // transmit to device #44 (0x2c)
27
// device address is specified in datasheet
28
Wire.write(byte(0x00)); // sends instruction byte
29
Wire.write(val); // sends potentiometer value byte
30
Wire.endTransmission(); // stop transmitting
32
val++; // increment value
33
if(val == 64) // if reached 64th position (max)
35
val = 0; // start over from lowest value