Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide Use hardware momentary switches to control moOde
#61
I tested my buttons with the script in the webpage that you indicated, displaying the button status. And it's weird because it doesn't stop changing, while I don't press the button. The result is:
Code:
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 0/GPIO.LOW/False - button not pressed
Port 25 is 0/GPIO.LOW/False - button not pressed
Port 25 is 0/GPIO.LOW/False - button not pressed
Port 25 is 0/GPIO.LOW/False - button not pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 1/GPIO.HIGH/True - button pressed
Port 25 is 0/GPIO.LOW/False - button not pressed
Port 25 is 0/GPIO.LOW/False - button not pressed
Port 25 is 0/GPIO.LOW/False - button not pressed
Port 25 is 0/GPIO.LOW/False - button not pressed
Port 25 is 0/GPIO.LOW/False - button not pressed
Port 25 is 0/GPIO.LOW/False - button not pressed
Port 25 is 1/GPIO.HIGH/True - button pressed


Any idea?
Reply
#62
Now I tested the same script, and I pressed the button 25: it is detected that I press it. But when I release it, its status is random: it changes from "pressed" to "not pressed", while I don't press it :Sad Really weird, I did not have issues on Volumio.
Reply
#63
@TheOldPresbyope You' re right, I was wrong Smile My setup is that GPIO pins are connected to +3V when I press the button. Sorry for the confusion Smile
Reply
#64
Maybe it's the circuit being used for GPIO interface.

Post some details about your hardware. Pi model, GPIO board if any, etc
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#65
I use RPI 3 with Allo Boss DAC + Allo Volt Amp
Between the Pi and the Boss, I have a GPIO breadboard to make the soldering easier.

But it would be weird because when I test the buttons with a multimeter, they work well. (I tested them without any power on the Pi though)
Reply
#66
Maybe there is a clue in the odd results from that script you tried earlier.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#67
OK, so now I've actually read Tim's earlier reply:

Code:
GPIO.setup(sw_1_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

I haven't played with the GPIO package but I interpret this line to mean the pin is enabled as an input pin with its internal pull-up resistor (within the RPi) enabled, which means the pin is already tied to +3.3v through ca 50Kohm. If this is so, then a push button which momentarily connects the pin to +3.3v won't cause a transition.

I expect you have either to change the code to enable the pull-down resistor or to change the switch to connect to ground instead of +3.3v.

Or I could be off in left field again Tongue

Regards,
Kent
Reply
#68
More info.

From (i) help in GPIO Config

- The GPIO button handler configures pins as input / pull-up.
- The pins are 3V3. Pins GPIO2 and GPIO3 have fixed pull-up resistors.
- At power on the pins are set to input mode, pins 0-8 are pull-ups to 3V3, pins 9-27 are pull-downs to 0V.

Power on state of GPIO pins
https://raspberrypi.stackexchange.com/qu...erup/51480

Rpi.GPIO - Configuring the pull up/down state in software.
https://sourceforge.net/p/raspberry-gpio...ki/Inputs/
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#69
Thanks for your additional comments.

@Tim Curtis : what would it mean for me? Does it give you an explanation of why the script shows that the state of the GPIO is constantly changing? If I don't press the button, it's like if there wasn't any button, so the state should not change, right?
Is there a piece of code in Moode that could affect the state of the GPIO?

@TheOldPresbyope : pushing the button does make a transition: in the small script that I run, if I press a button, the state of this GPIO remains "button pressed". While if I don't press a button, the state of this GPIO keeps changing

Thank  you again for your support and your investigation!
Reply
#70
I used another script, showing 0 or 1 every 0.1 second and I tested it with several GPIO, this is what I get:

Code:
1
1
0
1
0
1
1
0
1
0
1
1
0
1
0
1
0
0
1
0
1
0
1
1
0
1
0
1
1
0
0
1
1
Reply


Forum Jump: