qr gpio

 

Success:  At least as far as the qr reading and controlling the gpio pins are concerned.

Having now found some code at:

https://github.com/herbyme/zbar/tree/master/python/examples

I have got this to work with the ladder board or in effect the Raspberry pi GPIO.

I have therefore deleted the zbar-qrcode repository and created a new repository with just this new working code in,  set up to light up and switch off, the red leds.

https://github.com/zleap/helloworld.git

Grab the code in the usual way using git clone.  If you want to work on this your self you will need to fork,  then clone it,  you can then push code to your repository.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  newqrtoladder.py
#  
#  Copyright 2014 psutton <zleap@zleap.net>
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#  
#  
 
from sys import argv
import RPi.GPIO as GPIO
import zbar
import time
 
GPIO.setmode(GPIO.BOARD)
 
# su[ress warnings
GPIO.setwarnings(False)
 
# cleanup
GPIO.cleanup()
 
#setup pins
 
GPIO.setup(11, GPIO.OUT)
GPIO.setup(12, GPIO.OUT)
 
#all off
 
GPIO.output(11, False) # red 2
GPIO.output(12, False) # red 1
 
# create a Processor
proc = zbar.Processor()
 
# configure the Processor
proc.parse_config('enable')
 
# initialize the Processor
device = '/dev/video0'
if len(argv) > 1:
    device = argv[1]
proc.init(device)
 
# enable the preview window
proc.visible = True
 
# read at least one barcode (or until window closed)
for n in range(1, 5):
	proc.process_one()
	 There has to be more hackers out there who can help with this.  Where are you. 
 
# hide the preview window
proc.visible = False
 
# extract results
 
for symbol in proc.results:
    # do something useful with results
    print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data
 
if (symbol.data == "LedRedON"):
	GPIO.output(11, True) # turn led red 2 ON
	GPIO.output(12, True) # turn led red 1 ON
 
elif (symbol.data == "ledRedOFF"):
	GPIO.output(11, False) # turn led red 2 OFF
	GPIO.output(12, False) # turn led red 1 OFF

 

TO DO:

I still need to figure out how to read several codes in and then act on them one after the other.  Any ideas or code help welcome.