Help, Stuck on I2C 16 channel PWM Tutorial

Talk about Adafruit Raspberry Pi® accessories!

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Help, Stuck on I2C 16 channel PWM Tutorial

Postby Js3 » Tue Feb 12, 2013 6:02 pm

I've done everything up to changing the port on my RPi Rev2. It says( http://learn.adafruit.com/adafruit-16-c ... it-library) to make a change to the I2c default port but it seems like Im missing something. Everytime I use the sudo nano I dont get anything on the screen. I've tried from the home directory and from inside the Adafruit_PWM_Servo_Driver directory. Im doing something wrong, I tried running the example program but its not working so I know I have to change that port. I've done everything else up to this point right. Any help?
Js3
 
Posts: 6
Joined: Sun Sep 09, 2012 11:45 pm

Re: Help, Stuck on I2C 16 channel PWM Tutorial

Postby adafruit_support_bill » Wed Feb 13, 2013 7:11 am

Are you able to locate the file: Adafruit_PWM_Servo_Driver/Adafruit_PWM_Servo_Driver.py?
User avatar
adafruit_support_bill
 
Posts: 15893
Joined: Sat Feb 07, 2009 9:11 am

Re: Help, Stuck on I2C 16 channel PWM Tutorial

Postby Js3 » Wed Feb 13, 2013 1:01 pm

I typed in: cd Adafruit-Raspberry-Pi-Python-Code, then used the ls command these are my results below:

~/Adafruit-Raspberry-Pi-Python-Code/Adafruit_PWM_Servo_Driver $ ls
Adafruit_I2C.py Adafruit_PWM_Servo_Driver.py Servo_Example.py
Adafruit_I2C.pyc Adafruit_PWM_Servo_Driver.pyc
Js3
 
Posts: 6
Joined: Sun Sep 09, 2012 11:45 pm

Re: Help, Stuck on I2C 16 channel PWM Tutorial

Postby adafruit_support_bill » Wed Feb 13, 2013 1:09 pm

A .pyc file is the compiled version of the .py file. It is created automatically when you run it and would be impossible to edit. Try re-downloading the original .py source file from the repository: https://github.com/adafruit/Adafruit-Ra ... ython-Code
User avatar
adafruit_support_bill
 
Posts: 15893
Joined: Sat Feb 07, 2009 9:11 am

Re: Help, Stuck on I2C 16 channel PWM Tutorial

Postby Js3 » Wed Feb 13, 2013 1:21 pm

OK I finally got something besides a blank screen. (Wow that frustrating)

#!/usr/bin/python

import time
import math
from Adafruit_I2C import Adafruit_I2C

# ============================================================================
# Adafruit PCA9685 16-Channel PWM Servo Driver
# ============================================================================

class PWM :
i2c = None

# Registers/etc.
__SUBADR1 = 0x02
__SUBADR2 = 0x03
__SUBADR3 = 0x04
__MODE1 = 0x00
__PRESCALE = 0xFE


Is the "i2c = None" where I would change it to: self.i2c = Adafruit_I2C(address, bus=smbus.SMBus(1)) ?
Im new to Linux so Im sorry if this is trivial stuff going over my head
Js3
 
Posts: 6
Joined: Sun Sep 09, 2012 11:45 pm

Re: Help, Stuck on I2C 16 channel PWM Tutorial

Postby adafruit_support_bill » Wed Feb 13, 2013 1:28 pm

A little further down on line 30. The second line of this section:

Code: Select all
  def __init__(self, address=0x40, debug=False):
    self.i2c = Adafruit_I2C(address)
    self.address = address
    self.debug = debug
    if (self.debug):
      print "Reseting PCA9685"
    self.i2c.write8(self.__MODE1, 0x00)
User avatar
adafruit_support_bill
 
Posts: 15893
Joined: Sat Feb 07, 2009 9:11 am

Re: Help, Stuck on I2C 16 channel PWM Tutorial

Postby Js3 » Wed Feb 13, 2013 5:44 pm

It worked! :D Thanks for helping out this noob
Js3
 
Posts: 6
Joined: Sun Sep 09, 2012 11:45 pm


Return to Adafruit Raspberry Pi® accessories

Who is online

Users browsing this forum: No registered users and 2 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]