I want to control some L.E.D's through the GPIO ports depending on the value of "variable1" which will become a raw input. The problem is, if variable1==70 then both led 12 and 16 with light, but only 12 should be! when variable1==69 only led 16 will light, which is correct, if it is less than the "if" listed, both led will quickly flash once. I need to contain the code so it only runs on the single if. Can anyone advise what am I doing incorrect?
Thanks very much!
import.RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(12,GPIO.OUT) GPIO.setup(16,GPIO.OUT) variable1="70" if variable1=="71": print 'Too high' elif variable1=="70": print 'warning' GPIO.output(12,1) time.sleep(3) elif variable1=="69": print 'OK' GPIO.output(16,1) time.sleep(3) else: print 'fine' GPIO.cleanup()