![]() |
[How to do instruction] Use hardware momentary switches to control moOde - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: FAQ and Guides (https://moodeaudio.org/forum/forumdisplay.php?fid=9) +--- Thread: [How to do instruction] Use hardware momentary switches to control moOde (/showthread.php?tid=198) |
RE: Use hardware momentary switches to control moOde - sisim - 04-12-2020 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 Any idea? RE: Use hardware momentary switches to control moOde - sisim - 04-12-2020 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 : ![]() RE: Use hardware momentary switches to control moOde - sisim - 04-12-2020 @TheOldPresbyope You' re right, I was wrong ![]() ![]() RE: Use hardware momentary switches to control moOde - Tim Curtis - 04-12-2020 Maybe it's the circuit being used for GPIO interface. Post some details about your hardware. Pi model, GPIO board if any, etc RE: Use hardware momentary switches to control moOde - sisim - 04-12-2020 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) RE: Use hardware momentary switches to control moOde - Tim Curtis - 04-12-2020 Maybe there is a clue in the odd results from that script you tried earlier. RE: Use hardware momentary switches to control moOde - TheOldPresbyope - 04-12-2020 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 ![]() Regards, Kent RE: Use hardware momentary switches to control moOde - Tim Curtis - 04-12-2020 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/questions/51479/gpio-pin-states-on-powerup/51480 Rpi.GPIO - Configuring the pull up/down state in software. https://sourceforge.net/p/raspberry-gpio-python/wiki/Inputs/ RE: Use hardware momentary switches to control moOde - sisim - 04-13-2020 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! RE: Use hardware momentary switches to control moOde - sisim - 04-13-2020 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 |