title: Python Raspberry Pi GPIO and Wiegand issues
body: <p>I'm extremely new to Python, I've been learning a bit over the last couple weeks. This is what I've managed to come up with. I'm pretty over the moon the code works most of the time.<br/>
  <br/>
  I'm using 2 GPIO pins to read wiegand format from a reader to my Raspberry Pi 2. <br/>
  However, it doesn't always scan correctly. Occasionally scanning will hang on storing a bit and I'll have to fob the reader a second time to get it to finish. Sometimes it finishes correctly. Sometimes it finishes in a card number that is completely wrong. Usually fobbing a third time gets a new set of information that is correct. I've messed around with the c versions and python versions of PIGPIO to try understand what I'm doing differently. I can't figure out why it always seems to return a correct set of values from the reader using that code. I'm not knowledgeable enough to completely understand whats going on in the PIGPIO code so I'm unsure how to go about creating this consistency in my own code as I capture the information from the reader.<br/>
  <br/>
  Does anything pop out immediately to anyone that indicates a fault in my logic for reading the information from the reader?<br/>
  <br/>
  Remember, I'm super new so I need a little bit of hand holding with this.
  I'm looking to capture only 26 bit card format off an HID 26bit card reader. I have 3 different HID format fobs/cards and I've been using them to test. The issue happens utilizing the same fob over and over and if I cycle through them using one after the other. Sometimes it will scan fine for 10+ times, other times it'll fail immediately and not work for 2 or 3 scans.</p>
  
  <pre><code>from time import sleep
  import os
  import RPi.GPIO as GPIO
  import pifacecad as p
  GPIO.setmode(GPIO.BOARD)
  #GPIO setup
  data0=38
  data1=40
  GPIO.setup(data0,GPIO.IN,pull_up_down=GPIO.PUD_UP)
  GPIO.setup(data1,GPIO.IN,pull_up_down=GPIO.PUD_UP)
  #Setting up display
  cad = p.PiFaceCAD()
  cad.lcd.backlight_on()
  cad.lcd.clear()
  cad.lcd.cursor_off()
  cad.lcd.blink_off()
  cad.lcd.write("Ready")
  #Variables
  i=0
  dataBits=[]
  bitCount=1
  fcc="0"
  card="0"
  Zero="0"
  One="1"
  hexFilter=[]
  hexCard=[]
  hexFCC=[]
  justRead=0
  j=0
  k=0
  #Main code
  while (1):
      #Reading code
      while (bitCount&lt;27):   
          if GPIO.input(data0)==0:
              dataBits.append(Zero)
              print dataBits
              print "Bitcount %d" % bitCount
              bitCount = bitCount+1
              justRead=1
          if GPIO.input(data1)==0:
              dataBits.append(One)
              print dataBits
              print "Bitcount %d" % bitCount
              bitCount = bitCount+1
              justRead=1   
          if justRead ==1:
              if bitCount&gt;26:
      #Transforming our information into usable bits  
      #Rest of the code just handles the information and prints to a screen. 
      #The issue existed before I wrote the rest of the code
  </code></pre>
  
  <p>I'm using a voltage divide circuit with resistors to drop the 5v to 3v and my data lines and Pi are all grounded together.</p>
  
  <p><a href="https://i.stack.imgur.com/j8pYU.png" rel="nofollow noreferrer">Wiegand Hang</a>
  <a href="https://i.stack.imgur.com/vCyko.png" rel="nofollow noreferrer">Wiegand Wrong</a></p>
  
  <p>EDIT:
  Resolved here</p>
  
  <p><a href="https://raspberrypi.stackexchange.com/questions/42118/wiegand-gpio-read-not-working-all-the-time-works-most-times-but-hangs-on-some-r">https://raspberrypi.stackexchange.com/questions/42118/wiegand-gpio-read-not-working-all-the-time-works-most-times-but-hangs-on-some-r</a></p>