If you want to read low as the button is pressed, Yes.
I don’t have a MyVolumio account, that’s why I didn’t see the plugin search and I tried to install the plugin by myself… it’s fixed, I just created myself a account
Thanks for the help !
different buttons must be connected to different GPIOs.
in this picture Pause/Stop/Play are connected to the same GPIO, the RPi won’t be able to distinguish if a press is coming from Play or Stop or Pause.
unless he uses toggle?
Not true.
The resistor is holding the gpio low, all good so far.
When the button is pressed the GPIO will be short straight to 5V. Taking it higher than Mick Jagger on a concert weekend… NOT good. This may kill the Pi
should be using the 3.3v and an approprate current limiting resister
your correct, missed the 5V somehow.
Should be like this:
the max gpio current is 16mA.
so to be safe… also a 1k resistor in line with the gpio and switch will limit the max current allowed to flow to 3.3mA.
If you want to make it super stable a 100nf capacitor between GPIO and the ground to prevent accidental double pressing.
what i only don’t get why 3 buttons for the same press ? you could use only one for it.
pause stop play …
Good remark for the 3.3V and indeed a single button should be enough for play/stop/pause
As you can see bellow I am just finishing prototyping for my streamer and let me ask , what is the idea to have button only for “OFF” and not for “ON”. How you guys solve this in your streamers ?
Actualy I have 7 working buttons , 2 encoders and 3 LED connected to GPIO
Relay board is just my idea to have 2 separate buttons for Play and Pause and for one On/Off Button
it’s a hardware limitation of the rPi.
There is only software “on/off”. This means that “on/off” is the same button.
GPIO Buttons plugin has only software OFF so how to get one button for ON/OFF?
unfortunately GPIO3 is used by my DAC Hifiberry DAC2
Hello friends
play/pause works great with a button, but I need it to work with a switch (ON - Play, OFF - Pause) Does anyone know how to do this?
I would strongly advise against it. Adding a permanent switch means your pulling a GPIO up or down continuously. Which will end up in defects. (PMIC)
I have been using a switch connected in this way for a long time to turn off my raspberry and have not had any problems. I only use GPIO 26
then you could try something like this. PREV is added to hold the button state and avoid that the code keeps being executed. (code is not tested)
#!/bin/bash
# select pin GND - D0
GPIO0=26
# Print debug lines => 1 is print
debug=1
PREV=0
# Common path for all GPIO access
BASE_GPIO_PATH=/sys/class/gpio
# Utility function to export a pin if not already exported
exportPin()
{
if [ ! -e $BASE_GPIO_PATH/gpio$1 ]; then
echo "$1" > $BASE_GPIO_PATH/export
fi
}
# Utility function to set a pin as an output
setInput()
{
echo "in" > $BASE_GPIO_PATH/gpio$1/direction
}
exportPin $GPIO0
setInput $GPIO0
# If debug == 1
if [ $debug == 1 ]; then
echo "---------------------------------------------------"
printf "GPIO 0: %s\n" "${GPIO0}"
printf "STATUS 0: %s\n" "${STATUS0}"
fi
# continuously monitor current value
while true; do
sleep 1s
STATUS0=$(cat $BASE_GPIO_PATH/gpio${GPIO0}/value)
if [ $debug == 1 ]; then
echo "---------------------------------------------------"
printf "STATUS 0: %s\n" "${STATUS0}"
printf "PREV: %s\n" "${PREV}"
fi
if [ "$STATUS0" == 1 ] && [ "$PREV" == 0 ]; then
#Write here the code what needs to be done:
PREV=1
elif [ "$STATUS0" == 0 ] && [ "$PREV" == 1 ]; then
#Write here the code what needs to be done:
PREV=0
fi
done
when I run the script I get an error
GPIO 0: 26
STATUS 0:
play.sh: line 47: syntax error near unexpected token `do’
play.sh: line 47: ` do something.'Preformatted text