Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5608

Python • Re: Python3 code for ps4 controller mapping

$
0
0

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
Then you could decide your next action based on the state of the button simply by coding

Code:

if button_11 :

Statistics: Posted by B.Goode — Wed Jul 03, 2024 8:39 am



Viewing all articles
Browse latest Browse all 5608

Trending Articles