title: How can I use Raspberry pi gpio setup and pwm commands in __init__ function of a class?
body: <p>I am new at object oriented programming.I am working with Raspberry pi and I am building many classes which have different GPIO pins. I don’t know how to build setup and pwm comands. All of them should stay out of the classes or should I put them in <strong>init</strong> function for each class? How will it change for OOP in <strong>init</strong> function? Can you show me an example on this code?</p>
  
  <pre><code>GPIO.setup(33, GPIO.OUT)
  pwmservo=GPIO.PWM(33,50)
  pwmservo.start(6)
  
  class zmove(object):
      def __init__(self):
          pass
  
      def update(self,angle):
          duty=float(angle)/10.0+2.5
          pwmservo.ChangeDutyCycle(duty)
          time.sleep(0.3)
  </code></pre>