jehutting
Posts: 139
Joined: Sun Feb 15, 2015 8:37 am
Location: The Netherlands

Re: Screaming jellybaby programming

Sat Jan 09, 2016 10:39 pm

NOOOO....don't give up.

I have to say that you are doing a great job in coming so far :!: :!: :!: And you are almost there.

If you used the following burp.py code/file

Code: Select all

import time
import RPi.GPIO as GPIO
import os

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

GPIO.setup(3, GPIO.IN)

while True:
    if GPIO.input(3) == False:
        print("BURP")
        #os.system("omxplayer burp.wav")
        #time.sleep(1)
    time.sleep(1)
    print("x")
and you see the 'x' and 'BURP' printed on the terminal, your cables are placed on the right GPIO3/GND pins and the detection of you shortening the GPIO3 and GND works.

So to get sound you have to change the line

Code: Select all

#os.system("omxplayer burp.wav")
into

Code: Select all

os.system("omxplayer -o local burp.wav")
Remove the # and add -o local.

The # means that python sees the rest of the line as comment. In this case the os.system call is not executed and therefore no sound is played. I added the print BURP and this # in front of os.system just to check if the OP had the right GPIO pins and made the right connection.
So by removing the # the (os.system) command is now to be executed. By adding -o local you force omxplayer to use the jackplug to output the sound. If you use -o hdmi the sound output goes to your tv, and if you use -o both the sound goes to the jackplug and tv.

You will be rewarded for all your efforts.

hippy
Posts: 6233
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Screaming jellybaby programming

Sun Jan 10, 2016 3:13 pm

choice.locks wrote:I THerefore would recommend that you don't use this suggested gpio demonstration to impress your kids because it wont. My boy lost interest 2 weeks ago. So i am going to have to give it a break and put it back in the box for a couple of weeks and reintroduce it with hopefully a project that does work.
Perhaps you could spend some time familiarising yourself with your Pi, Python and any tutorials you may later be using before introducing them to your son, trying them out, getting them to work.

I can sympathise with your son's loss of interest as I have also had to sit there, getting increasingly bored, watching people struggle to do something they have little clue about. That's not the best way to engender enthusiasm for anything.

User avatar
liz
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 5202
Joined: Thu Jul 28, 2011 7:22 pm
Contact: Website

Re: Screaming jellybaby programming

Sun Jan 10, 2016 3:22 pm

I'm very sorry this exercise didn't work out for the OP - but it'd be very wrong for people to dismiss this activity on the basis of this poster's experience. We're aware of tens of thousands of people who have worked through this tutorial without any problems and who have enjoyed it and learned from it. It's used regularly in schools and in clubs and workshops.

If nothing else, this poster's experience really underlines the importance of reading carefully, making no errors when you copy something out, and paying attention!
Director of Communications, Raspberry Pi

1lovcars
Posts: 26
Joined: Mon Dec 28, 2015 4:41 pm
Location: South Carolina, USA

Re: Screaming jellybaby programming

Sun Jan 10, 2016 3:54 pm

liz wrote:I'm very sorry this exercise didn't work out for the OP - but it'd be very wrong for people to dismiss this activity on the basis of this poster's experience. We're aware of tens of thousands of people who have worked through this tutorial without any problems and who have enjoyed it and learned from it. It's used regularly in schools and in clubs and workshops.

If nothing else, this poster's experience really underlines the importance of reading carefully, making no errors when you copy something out, and paying attention!
Liz, I appreciate the post and dedication. But if you read thru the posts and then my and others posts and threads that were similar, you'll see that there are issues. I was able to work thru and get this one to work.. though, it isn't exactly like the worksheet. My son and I are now on the second project he picked (people in space) and we're seeing issues with that worksheet as well. I certainly wouldn't expect it to be perfect... and you'd think there to be issues from time to time. Though, I'd say we're 2 for 2 on these projects not being as described in the worksheet. Fortunately I enjoy the hunt for a solution... even if it brings me here to the forums where I've found folks to be very helpful!!!! :D

Return to “Beginners”