Help, Stuck on I2C 16 channel PWM Tutorial
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/
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/
- js3
- Posts: 24
- Joined: Mon Sep 10, 2012 12:45 am
Help, Stuck on I2C 16 channel PWM Tutorial
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?
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Help, Stuck on I2C 16 channel PWM Tutorial
Are you able to locate the file: Adafruit_PWM_Servo_Driver/Adafruit_PWM_Servo_Driver.py?
- js3
- Posts: 24
- Joined: Mon Sep 10, 2012 12:45 am
Re: Help, Stuck on I2C 16 channel PWM Tutorial
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
~/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
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Help, Stuck on I2C 16 channel PWM Tutorial
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
- js3
- Posts: 24
- Joined: Mon Sep 10, 2012 12:45 am
Re: Help, Stuck on I2C 16 channel PWM Tutorial
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
#!/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
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Help, Stuck on I2C 16 channel PWM Tutorial
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)
- js3
- Posts: 24
- Joined: Mon Sep 10, 2012 12:45 am
Re: Help, Stuck on I2C 16 channel PWM Tutorial
It worked! Thanks for helping out this noob
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/
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/