~ubuntu-branches/debian/experimental/arduino/experimental

« back to all changes in this revision

Viewing changes to libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2012-03-11 18:19:42 UTC
  • mfrom: (1.1.5) (5.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20120311181942-be2clnbz1gcehixb
Tags: 1:1.0.1~rc1+dfsg-1
New upstream release, experimental.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// I2C Digital Potentiometer
2
 
// by Nicholas Zambetti <http://www.zambetti.com>
3
 
// and Shawn Bonkowski <http://people.interaction-ivrea.it/s.bonkowski/>
4
 
 
5
 
// Demonstrates use of the Wire library
6
 
// Controls AD5171 digital potentiometer via I2C/TWI
7
 
 
8
 
// Created 31 March 2006
9
 
 
10
 
// This example code is in the public domain.
11
 
 
12
 
// This example code is in the public domain.
13
 
 
14
 
 
15
 
#include <Wire.h>
16
 
 
17
 
void setup()
18
 
{
19
 
  Wire.begin(); // join i2c bus (address optional for master)
20
 
}
21
 
 
22
 
byte val = 0;
23
 
 
24
 
void loop()
25
 
{
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
31
 
 
32
 
  val++;        // increment value
33
 
  if(val == 64) // if reached 64th position (max)
34
 
  {
35
 
    val = 0;    // start over from lowest value
36
 
  }
37
 
  delay(500);
38
 
}
39