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
.
Asked
Active
Viewed 2,412 times
0
1 Answers
1
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():
GPIO.output(18,HIGH)
Or make it a lambda:
light1ON = lambda : GPIO.output(18,HIGH)

user268396
- 11,576
- 2
- 31
- 26
-
Thank you so much. I was overthinking it all. haha – Apr 10 '16 at 21:41