title: Python Raspberry Pi GPIO error
body: <p>I am running the following python script on my Raspberry Pi:</p>
  
  <p><a href="http://www.skpang.co.uk/dl/rfid.py" rel="nofollow">http://www.skpang.co.uk/dl/rfid.py</a></p>
  
  <p>I've modified the script towards the end to access the GPIO pin 15 and turn it on and off. Here is my code at the bottom:</p>
  
  <pre><code>def example():
  
  rfid = SL030()
  fw = rfid.get_firmware()
  print("RFID reader firmware:" + fw)
  print()
  
  GPIO.setmode(GPIO.BOARD)
  GPIO.setup(15, GPIO.OUT)
  GPIO.output(15,True)
  
  
  while True:
      rfid.wait_tag()
      print("card present")
  
      if rfid.select_mifare():
          type = rfid.get_type()
          print("type:" + rfid.get_typename(type))
  
          id = rfid.get_uidstr()
          try:
              user = cards[id]
              print(user)
              #os.system("aplay " + user)
          except KeyError:
              print("Unknown card:" + id)
  
      rfid.wait_notag()
      print("card removed")
      print()
  </code></pre>
  
  <p>Problem i am facing is that although it operates pin 15, the script halts with the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "./rfid.py", line 212, in &lt;module&gt;
      example()
    File "./rfid.py", line 182, in example
  rfid.wait_tag()
    File "./rfid.py", line 45, in wait_tag
  while not self.tag_present():
    File "./rfid.py", line 40, in tag_present
      return GPIO.input(CFG_TAG_DETECT) == False
      RPi.GPIO.InvalidChannelException: The channel sent is invalid on a Raspberry Pi
  </code></pre>
  
  <p>Any ideas what can be wrong?</p>
  
  <p>Thanks</p>
  
  <p><em><strong>UPDATE</em></strong></p>
  
  <p>If i put the GPIO code just below the def example(): and above the rfid = SL030() like below, then it seems to work without error:</p>
  
  <pre><code>def example():
  
      GPIO.setmode(GPIO.BOARD)
      GPIO.setup(15, GPIO.OUT)
      GPIO.output(15,True)
  
      rfid = SL030()
  </code></pre>
  
  <p>*<strong><em>UPDATE - SOLUTION</em>*</strong></p>
  
  <p>Thanks to André, i changed:</p>
  
  <pre><code>GPIO.setmode(GPIO.BOARD)
  </code></pre>
  
  <p>to: 
      GPIO.setmode(GPIO.BCM)</p>
  
  <p>and then changed the port to match the BCM port like this:</p>
  
  <pre><code>GPIO.setup(22, GPIO.OUT)
  GPIO.output(22,True)
  </code></pre>