title: Controlling LED's with PCA9685
body: <p>I have bought an Adafruit PCA9685 and completed the library installation, however, I have no clue of how to Program it. I want to base it on the following code I wrote: </p>
  
  <pre><code>import RPi.GPIO as GPIO
  import time
  import sys
  from pubnub import Pubnub
  
  GPIO.setmode(GPIO.BCM)
  
  PIN_LIVING = 22
  PIN_PORCH = 17
  PIN_FIREPLACE = 27
  
  GPIO.setup(PIN_LIVING,GPIO.OUT)
  GPIO.setup(PIN_PORCH,GPIO.OUT)
  GPIO.setup(PIN_FIREPLACE,GPIO.OUT)
  
  FREQ = 100 # frequency in Hz
  FIRE_FREQ = 30 #  flickering effect
  
  # Duty Cycle (0 &lt;= dc &lt;=100)
  
  living = GPIO.PWM(PIN_LIVING, FREQ)
  living.start(0)
  
  porch = GPIO.PWM(PIN_PORCH, FREQ)
  porch.start(0)
  
  fire = GPIO.PWM(PIN_FIREPLACE, FIRE_FREQ)
  fire.start(0)
  
  # PubNub
  
  pubnub = Pubnub(publish_key='demo', subscribe_key='demo')
  
  channel = 'pi-house'
  
  def _callback(m, channel):
      print(m)
  
      dc = m['brightness'] *10
  
      if m['item'] == 'light-living':
          living.ChangeDutyCycle(dc)
  
      elif m['item'] == 'light-porch':
          porch.ChangeDutyCycle(dc)
  
      elif m['item'] == 'fireplace':
          fire.ChangeDutyCycle(dc)
  
  def _error(m):
    print(m)
  
  pubnub.subscribe(channels='pi-house', callback=_callback, error=_error)
  
  try:
      while 1:
          pass
  except KeyboardInterrupt:
      GPIO.cleanup()
      sys.exit(1)
  </code></pre>
  
  <p>I dont know if on this its similar. I bought it because I wanted to be able to control more LED's with PWM from the Raspberry pi. I looked into it and found all kinds of weird commands and terms specific to this Chip.</p>
  
  <p>Thanks!</p>