Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Adafruit_PWM_Servo_Driver on rev 2 Raspberry Pi #40

@micahflee

Description

@micahflee

I have a 16 channel servo driver (https://www.adafruit.com/products/815) that I connected to my Raspberry Pi rev 2, and now I'm trying to send data over I2C to make the motor work.

I'm trying to follow the instructions at http://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi/using-the-adafruit-library.

It says to clone this repo:

$ git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
$ cd Adafruit-Raspberry-Pi-Python-Code
$ cd Adafruit_PWM_Servo_Driver

It also says to change the self.i2c = Adafruit_I2C(address) line, for the rev 2 Raspberry Pi:

If you have a second revision raspberry Pi, you'll need to update the default I2C port.  In the file Adafruit_PWM_Servo_Driver/Adafruit_PWM_Servo_Driver.py

change
self.i2c = Adafruit_I2C(address)
to
self.i2c = Adafruit_I2C(address, bus=smbus.SMBus(1))

You also need to add import smbus to the top of the file.

When I follow these instructions and then run "sudo python Servo_Example.py", I get this error:

[pi@raspberrypi] {master} ~/adafruit/Adafruit-Raspberry-Pi-Python-Code/Adafruit_PWM_Servo_Driver$ sudo python Servo_Example.py
Traceback (most recent call last):
  File "Servo_Example.py", line 12, in <module>
    pwm = PWM(0x40, debug=True)
  File "/home/pi/adafruit/Adafruit-Raspberry-Pi-Python-Code/Adafruit_PWM_Servo_Driver/Adafruit_PWM_Servo_Driver.py", line 31, in __init__
    self.i2c = Adafruit_I2C(address, bus=smbus.SMBus(1))
TypeError: __init__() got an unexpected keyword argument 'bus'

It looks like the Adafruit_I2C constructor doesn't let me pass in a bus? Do you know how I can get this working on my rev 2 RPi? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions