I wanted to set up a plause/play button on the Raspberry Pi Zero, but when I tried the script that worked successfully on the Raspberry Pi 3:
#!/usr/bin/env python2
import RPi.GPIO as GPIO
import subprocess
GPIO.setmode(GPIO.BOARD)
#Select an unused GPIO header pin as input
InputPin = 11
# Set pin to input, and enable internal pull-up
GPIO.setup(InputPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# Wait for a button press on the selected pin (pin pulled to ground, falling edge)
GPIO.wait_for_edge(InputPin, GPIO.FALLING)
# When pressed, execute the mpc toggle command:
print "*** Button press detected ***" # (print statement added for debugging)
subprocess.call("mpc toggle", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
I got a message that the RPi.GPIO module was not found.
I know that the PiZero has the same GPIO numbers as the Pi3, but I believe the Rune image I am using is based on the Raspberry Pi 1, which has different GPIO numbers.
Do I need to alter the code, or do I need to install the RPi.GPIO module? If so, how?
Thanks,
Rod