I got a Raspberry PI 4B with Volumio 2.681 and IQaudio DAC+. And I got a python script which is successfully tested on raspberry pi OS but it don’t work on Volumio:
import RPi.GPIO as GPIO import time button1 = 13 button2 = 16 button3 = 18 button4 = 22 button5 = 37 led = 11 def setup(): print("Setup Buttons") GPIO.setmode(GPIO.BOARD) GPIO.setup(button1, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(button2, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(button3, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(button4, GPIO.IN, pull_up_down=GPIO.PUD_UP) #GPIO.setup(button5, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(led, GPIO.OUT) print("Setup finished") def loop(): while True: buttonPushed(button1) buttonPushed(button2) buttonPushed(button3) buttonPushed(button4) #buttonPushed(button5) def endprogram(): GPIO.output(led, False) GPIO.cleanup() def buttonPushed(pin): buttonState = GPIO.input(pin) if buttonState == 0: GPIO.output(led, True) print("Button on GPIO " + str(pin) + " pushed") while GPIO.input(pin) == 0: time.sleep(0.2) else: GPIO.output(led, False) if __name__ == '__main__': setup() try: loop() except KeyboardInterrupt: print ('keyboard interrupt detected') endprogram()
A simple program to test the buttons, but I only get the message “Button on GPIO 13 pushed”. It seems there’s something wrong with my setup. Is there something I have to know about Volumio and GPIOs or do I need an update on wiringpi? I haven’t found anything in the forums and docs.
Any help would be appreciated.
PS: I don’t want to use the GPIO plugin