I have 4 LEDs connected to GPIO outputs of a Raspberry Pi. I want to use the argv command so that I can select the LEDs using a simple binary code. For example:
python test.py 1010
This would light up the first and third LEDs in the row. The problem is I don't think Im approaching this correctly. Here is my code so far
from sys import argv
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(12, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
x, y = argv
print "Script:", x
if y == '0000':
GPIO.output(11, 0)
GPIO.output(12, 0)
GPIO.output(13, 0)
GPIO.output(15, 0)
if y == '0001':
GPIO.output(11, 0)
GPIO.output(12, 0)
GPIO.output(13, 0)
GPIO.output(15, 1)
GPIO.cleanup()
Im leaving out the rest of the combinations so I dont bloat this question. Im running into several syntax issues, but Im wondering if I should just scrap this and go about it another way. Im new and any advice would be appreciated.