Any advice would be appreciated as I'm new to Python programming.
As it says in your photo, but in different words.
button_11 and button_12 are boolean variables - they are either True or False. (It would help to see the part of the script where their values are set.)
'on' is a string - a sequence of characters. You probably intend it to represent whether an LED, switch or other circuit has been turned on?
It is simply not meaningful to compare True/False with 'some characters'
One solution would be to use the constants provided by the RPi.GPIO library, which you have used elsewhere.
Something like -
Code:
if button_11 == GPIO.HIGH :
Even that is over-complicated because it contains redundant information. Although its intent is fairly clear.
The comparison in an if statement must evaluate to a Boolean - True or False.
Assuming that button_11 got its value from something like
Code:
button_11 = GPIO.input(11) # Just guessing that this might be what your script uses
Code:
if button_11 :
Although it is beyond what you asked about, be aware that although the RPi.GPIO library works on your RPi4 board with your present script it is unsupported by Raspberry Pi. Some features may not work as you expect and your code will not run on a later RPi[5] board should you choose to upgrade later.
Raspberry Pi recommend the alternative gpiozero Python library. Adapting to that library now might save you some re-learning later.
Ref: Use GPIO from Python - https://www.raspberrypi.com/documentati ... rom-python
Statistics: Posted by B.Goode — Wed Jul 03, 2024 8:39 am