Controlling 12 servos with I2C Servo Controller IC

Controlling 12 servos with I2C Servo Controller IC

Here is a straightforward sketch to interface with our 12 channel Servo Controller IC.

The servo controller IC easily allows you to add up to 96 servos (8x Servo Controller chips) to your Arduino project. Enough for even the most advanced robot.

  1. Simply connect +5V to pin 1 on the chip
  2. Connect 0V to pin 20 on the chip.
  3. Connect the I2C SDA pin from the Arduino (A4 on Uno)  to the SDA pin on the servo chip (pin 13)
  4. Connect the I2C SCL pin from the Arduino (A5 on Uno)  to the SCL pin on the servo chip (pin 11)
  5. Connect pullup resistors (4k7) on SCL and SDA to +5V
  6. Connect the servo signal wire (usually orange) to one of the servo chip SERVO outputs.
  7. Connect the servo power wire (usually red) to +5V
  8. Connect the servo ground wire (usually black) to +0V
  9. Connect the three address pins on the servo chip to ground

The sketch rotates each servo through its full range of motion, then pauses for short while, then repeats.

/*
** Wire Master of Hobbytronics 12 channel SERVO Controller
** Sweeps all 12 servos from one end to the other continuously
** Created 04 May 2010
**
** This example code is in the public domain.
** www.hobbytronics.co.uk
*/

#include <Wire.h>

const int  servoslave_address=40;   // I2C Address of ADC Chip 
void setup()
{
  Wire.begin();              // join i2c bus (address optional for master)

  // Optionally set mode to standard 
  // – comment out this section if extended mode required
  Wire.beginTransmission(servoslave_address); // transmit to device
  Wire.send(20);             // servo register address 20
  Wire.send(0);              // send value 0 for standard mode
  Wire.endTransmission();    // stop transmitting 
  delay(1);                  // waits  

}


void loop()
{
  unsigned char i,j;

  for(i = 127; i < 255; i++)      // goes from center to full right
  {                                  
    Wire.beginTransmission(servoslave_address); // transmit to device
    Wire.send(0);               // servo register to start from
    for(j=0;j<12;j++)
    {  
       Wire.send(i);           // send 12 bytes of data
    }
    Wire.endTransmission();    // stop transmitting  
    delay(1);                  // waits
  } 
  for(i = 255; i > 0; i--)     // goes from full right to full left
  {                          
    Wire.beginTransmission(servoslave_address); // transmit to device
    Wire.send(0);               // servo register to start from    
    for(j=0;j<12;j++)
    {  
       Wire.send(i);           // send 12 bytes of data
    }
    Wire.endTransmission();    // stop transmitting  
    delay(1);                  // waits
  }
  for(i = 0; i < 127; i++)     // goes from full left back to center
  {                          
    Wire.beginTransmission(servoslave_address); // transmit to device
    Wire.send(0);               // servo register to start from    
    for(j=0;j<12;j++)
    {  
       Wire.send(i);           // send 12 bytes of data
    }
    Wire.endTransmission();    // stop transmitting  
    delay(1);                  // waits
  } 
  delay(800);                  // waits for 0.8 seconds
}

Shopping Cart
0 items
 
DELIVERY/PAYMENT

Free Delivery Orders over £50

UK - £2.40 orders under £50
Airmail from £2.95 (+VAT)
More Details...

 
Brands
 
 Check out our videos