Can GPIO.output
be assigned to a variable like light1ON = GPIO.output(18,HIGH)
in python? Because when I do this it automatically turns the light on even knowing I didn't call light1ON
.
When you do this:
light1ON = GPIO.output(18,HIGH)
You actually call the GPIO.output
as a function passing it two parameters, and assign the resulting value to light1ON
.
If you want light1ON
to be a function either def
it as a function:
def light1ON():
return GPIO.output(18,HIGH)
Or make it a lambda:
light1ON = lambda : GPIO.output(18,HIGH)