How it works:
A barcode scanner attached to the Raspberry Pi scans one barcode (on the outside of a box) and another scanner scans another barcode (maybe on the inside of the box. Packing list or invoice). If the two are a match, a green LED flashes and the motor running the conveyor continues to run. If the two barcodes do not match then the motor stops and a red light comes on. A button is also attached to the Raspberry Pi to reset and start again.
The code that I created is works, it just seems too simple. I don't want it to just work, I want it to be correct. There's got to be like six more pages of code that I'm missing, right?
Code: Select all
# 4 Line Switch Off/On # 17 Error light # 23 Good Scan # 18 Reset Button import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(4, GPIO.OUT) GPIO.output(4, True) GPIO.setup(17, GPIO.OUT) GPIO.output(17, True) GPIO.setup(23, GPIO.OUT) GPIO.output(23, True) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) import time GPIO.wait_for_edge(18, GPIO.RISING) while True: GPIO.output(4, False) GPIO.output(17, True) GPIO.output(23, True) if raw_input("1st Scan:") == raw_input("2nd Scan:"): GPIO.output(23, False) time.sleep(.3) GPIO.output(23, True) continue else: print("NO MATCH") GPIO.output(4, True) GPIO.output(17, False) GPIO.wait_for_edge(18, GPIO.RISING) continue