1

I am quite new to using the Raspberry Pi2. Currently I am trying to run the Screaming Jelly Baby program in Python by using the GPIO pins https://www.raspberrypi.org/learning/screaming-jellybaby/worksheet/

The problem I am getting is that when I run the program the .wav file is just continuously playing. This should only play when I touch the two paper clips together.

My code is as follows:

import time
import RPi.GPIO as GPIO
import os

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(26,GPIO.IN)
while True:
    if GPIO.input(26) == False:
        os.system('mpg321 scream.mp3')
        time.sleep(1)

I know I am using pin 26. This is because when I try running on pin 3 I get the following message:

Warning (from warnings module): File "/home/pi/burp.py", line 7 GPIO.setup(3,GPIO.IN) RuntimeWarning: A physical pull up resistor is fitted on this channel!

Help with this would really be appreciated.

  • 1
    The message is saying you are not running as root. It says nothing about using the correct pin or not. – joan Apr 25 '15 at 21:36
  • further to what Joan said run your script with sudo python your scripts name so assuming your script was called screaming.py you would run sudo python screaming.py – Steve Robillard Apr 25 '15 at 21:41
  • Sorry I copied the wrong error message. I am getting the following error message when using pin 3: Warning (from warnings module): File "/home/pi/burp.py", line 7 GPIO.setup(3,GPIO.IN) RuntimeWarning: A physical pull up resistor is fitted on this channel! Any ideas on how to solve the problem of the program continuing to play the sound file even when the paper clips are not touching? – allred Apr 26 '15 at 9:09
1

Looking at the code it looks like you are checking if input on that pin is false then play the audio file so you just need to change that to True and it should work.

Try this:

import time
import RPi.GPIO as GPIO
import os

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(26,GPIO.IN)
while True:
    if GPIO.input(26) == True:
        os.system('mpg321 scream.mp3')
        time.sleep(1)
  • I have tried with changing it to True. I am still getting the same problem. – allred Apr 29 '15 at 17:37
  • @allred This might not work but try setting GPIO.setwarnings(False) to true. If that doesn't work then try making an else statement to break. Sorry for the late reply. – one2three May 6 '15 at 19:51
  • If non of my suggestions work then it might be a problem with the circuit. – one2three May 6 '15 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.