User avatar
DougieLawson
Posts: 36875
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Screaming jellybaby programming

Fri Jan 01, 2016 11:37 am

Python is a cAsE sEnSiTiVe language so "FALSE" is not equal to "False" and it's not equal to "false" either.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

jbudd
Posts: 1057
Joined: Mon Dec 16, 2013 10:23 am

Re: Screaming jellybaby programming

Fri Jan 01, 2016 11:52 am

I'm glad that you have finally got the jellybaby to burp.

By struggling through you have probably learned a lot more than if it all worked first time.

For instance you now know:
The importance of letter perfect typing. No spaces in the wrong place, no capitals where small letters are needed.
How to modify the way commands work with parameters such as -o local
The difference between the command line and a stored program.
That people are happy to help but can be very confusing.
That computing is frustrating.

Happy new year!

Navyscourge
Posts: 258
Joined: Sat Oct 24, 2015 1:50 pm

Re: Screaming jellybaby programming

Fri Jan 01, 2016 2:30 pm

Really guys... think first. Given what we have told choice.locks about getting this example to work and their problems, you are now suggesting they use Github to report a problem, or even to suggest a solution.

The instructions in the exercise say use amixer to set the headphones, and we say use the option on omxplayer - this may have the same effect, but is it really a problem in the exercise? Surely we can work out what problems users are having, and check the instructions ourselves, knowing all that we do, are report an issue or improvement if users report it here. We are trying to help people who are new to the Pi and are experiencing problems in documentation written to help them.

@choice.locks - sorry to see you are being given such advice - please keep reporting problems here and ignore GitHub

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Fri Jan 01, 2016 11:20 pm

Update so far although i can make the test file run by inserting -o local into the test program
I still can't make the jelly baby connection. We have even joined the leads together.
I got a youngster who studied programming in college for 2 years and was familiar with linux. to sit with me to go through all of it again this evening. But still no result. We have both come to the conclusion that there is a fundamental error in the instructions.
So come on guys who's up for the challenge try it yourself make it work then tell us all how you did it.
Or tell us what is wrong with the instructions.
I lay the gauntlet down.
This noob is saying raspberry pi have got it wrong. Prove me wrong and I will happily admit defeat. :x

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

Re: Screaming jellybaby programming

Sat Jan 02, 2016 1:58 am

Not sure where you are having the issues at this point. But as you may have seen there are two other threads I was in trying to figure this thing out too. Take a look at this thread and see if you can change the code to print "x" and "burp" on the screen. Or get to the point where it runs by launching in the terminal window instead of inside the python window.

viewtopic.php?f=28&t=121664

User avatar
DougieLawson
Posts: 36875
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Screaming jellybaby programming

Sat Jan 02, 2016 2:22 am

The whole program isn't exactly complex.

Code: Select all

#!/usr/bin/python3

import time
import RPi.GPIO as GPIO
import os

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(3, GPIO.IN)

try:
   while True:
      if GPIO.input(3) == False:
         print ("Jelly baby touch detected")
         os.system("omxplayer burp.wav")
         time.sleep(1)
except:
   GPIO.cleanup()
I've added a couple of lines to trap [CTRL]+[C] to make the program terminate cleanly and to do something even if omxplayer fails to run.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Sat Jan 02, 2016 5:40 am

Got following message after running
Warning (from warnings module):
File "/home/pi/ jellybaby/burp.py", line 11
GPIO.setup(3, GPIO.IN)
RuntimeWarning: A physical pull up resistor is fitted on this channel

Also
I did not understand your final part of the instruction about (ctrl) (c)

User avatar
rpdom
Posts: 15913
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Screaming jellybaby programming

Sat Jan 02, 2016 10:29 am

choice.locks wrote:Got following message after running
Warning (from warnings module):
File "/home/pi/ jellybaby/burp.py", line 11
GPIO.setup(3, GPIO.IN)
RuntimeWarning: A physical pull up resistor is fitted on this channel

Also
I did not understand your final part of the instruction about (ctrl) (c)
Don't worry about the warning message. It is to be expected when you use that pin. It's just letting you know, in case you weren't sure.

When a program is running (in a terminal), holding down the "Ctrl" key and pressing the "C" key will tell the program to stop (with an error message). The "trap" that dougie put in makes the program end cleanly if there is an error or you press Ctrl-C while it is running.

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Sat Jan 02, 2016 6:08 pm

Ok somi got the warning message which i could ignore if it made the jellybaby burp when the wires were pressed together.
But.
It still doesnt work?

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Sat Jan 02, 2016 11:27 pm

Progress so far
Finally changed keyboard language somthat i can get hash bang symbols
#!

So fully entered dougies programming in python3 and saved
Then ran the programme using module f5 drop down menu
Same error message as above and putting wires together still does not generate sound

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Sat Jan 02, 2016 11:37 pm

I can only play the test file in the terminal screen by inserting
-o local
It will not play as burp.wav alone
I then altered dougies program by inserting -o local between
os.system("omxplayer and burp.wav")
Like this ("omxplayer -o local burp.wav")

But again no sound when i ran the program

jbudd
Posts: 1057
Joined: Mon Dec 16, 2013 10:23 am

Re: Screaming jellybaby programming

Sun Jan 03, 2016 12:49 am

Oh I thought you had it working but clearly I misunderstood.

My Pi setup is different from yours because I don't have a screen, so no desktop interface and no idle3 Python development environment. No jellybabies either.
Nevertheless I tried to repeat your steps and it worked. When I touched the wires together I heard the burp in my headphones.

If you wish I can detail everything I did.

Your setup does not work. So something is different...
- Have you made doubly sure that your jumper wires are plugged onto the right pins? Perhaps you can post a photo?
- I didn't like the paperclips pushed into the jumper wires - plenty of scope for a bad contact there. So I used two female - male jumper wires and touched the exposed male ends together.
- Perhaps something strange happens when you run the program from idle3. Is your file burp.py in the same folder as burp.wav? The first line in Dougie's code allows you to run the program from the command line like this:

Code: Select all

python ./burp.py

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Sun Jan 03, 2016 9:37 am

Thanks i will give it a try and detailed pics and results later today

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Sun Jan 03, 2016 4:51 pm

Ok here is an outline of what i am doing from start to finish
Boot up raspberry pi
Enter
Pi press return key
Raspberry press return key
startx press return key
Double click on (terminal) desktop icon

Enter Into where i see pi@raspberrypi ~ $ cd jellybaby
Press return key
I then get
Pi@raspberrypi ~ jellybaby $

I then enter sudo idle3 & and press return
The terminal screen then displays
[1] 2310
Pi@raspberrypi ~/jellybaby $

And opens the python shell screen
Imthen click on file open and select the file name burp.py
And open
The code in this file reads as follows
#!/usr/bin/python3

import time
import RPi.GPIO as GPIO
import os

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(3, GPIO.IN)

try:
while true:
if GPIO.input(3) == False:
Print ("Jelly baby touch detected")
os.system("omxplayer -o local burp.wav")
time sleep (1)
except:
GPIO.cleanup ()

I then save the file
Click on run
And then run module F5

The error message i receive is

The following error message

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

I would send a photo of the pins but don' know how to include on this page
This is a descrition of the pins i am using

Last 6 pins nearest to sd card
531
642

If number 2 was neaest to the the outside corner by sd card
I have connected the wires to,pins
5 and 6 in the above illustration
Gpio 3
And ground

Hope this helps i think it will be something small but obvious to the right person that i am doing wrong

User avatar
DougieLawson
Posts: 36875
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Screaming jellybaby programming

Sun Jan 03, 2016 7:56 pm

choice.locks wrote: I then enter sudo idle3 & and press return
What happens if you enter
sudo python3 /home/pi/burp.py
and press return at that point?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Sun Jan 03, 2016 8:49 pm

Where do you want me to type that last instruction terminal or python please

User avatar
rpdom
Posts: 15913
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Screaming jellybaby programming

Sun Jan 03, 2016 8:57 pm

choice.locks wrote:Where do you want me to type that last instruction terminal or python please
In the terminal please.

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Sun Jan 03, 2016 9:01 pm

I dont quite know how it worked and am struggling to repeat it
But there is some truth in the link followed by 1lovcars

Who wrote Okay we got it to work!!! Though not in the python shell as the worksheet states.
We found that you can start the program by typing "sudo python burp.py" and by following the advice on the other thread it runs and burps in the terminal window

I tried some of this though i can't repeat it at present and I had a series of xxxx after the error message about the resistor, and each time the wires were put together it wrote burp on screen

So i think i am completing the circuit just not generating sound but how i did it i can' quite follow again but i think the answer is somewhere in his post

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

Re: Screaming jellybaby programming

Sun Jan 03, 2016 11:30 pm

choice.locks wrote:I dont quite know how it worked and am struggling to repeat it
But there is some truth in the link followed by 1lovcars

Who wrote Okay we got it to work!!! Though not in the python shell as the worksheet states.
We found that you can start the program by typing "sudo python burp.py" and by following the advice on the other thread it runs and burps in the terminal window

I tried some of this though i can't repeat it at present and I had a series of xxxx after the error message about the resistor, and each time the wires were put together it wrote burp on screen

So i think i am completing the circuit just not generating sound but how i did it i can' quite follow again but i think the answer is somewhere in his post
I think we are nearly having the same issue or close to it. I can get it to do the sound when I execute the program in the terminal. "sudo python burp.py". It will not make the sound when executing thru the python shell and actually freezes the window. I think it actually has something to do with Python itself, not the code that we are writing. Perhaps an update or something that isn't pushed to it when we follow the instructions for updating and upgrading the Pi itself.

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Mon Jan 04, 2016 4:56 pm

Ok nice to know i am not alone i wish the raspberry pi people would take this up as there is obviously a big fault here. Especially as its one of thre introductory learning demos.

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

Re: Screaming jellybaby programming

Mon Jan 04, 2016 6:26 pm

choice.locks wrote:

Code: Select all

try:
   while true:
        if GPIO.input(3) == False:
           Print ("Jelly baby touch detected")
           os.system("omxplayer -o local burp.wav")
           time sleep (1)
except:
     GPIO.cleanup ()
That "true" should be "True". That will generate a runtime error but, as it's inside a try...except block, it is caught and ignored. My guess is the program is running and then silently ending when that error occurs.

And you need to fix the "Print" as well or the same thing will happen again with that.

And put the missing period in "time sleep".

I can understand wanting to clean up at the end of the program but that try...except block is a very bad idea as it obscures all errors within it.

Navyscourge
Posts: 258
Joined: Sat Oct 24, 2015 1:50 pm

Re: Screaming jellybaby programming

Mon Jan 04, 2016 8:44 pm

I have had my finger "poised" over the proverbial button for a while now, waiting to report this, but I have yet to see a RELIABLE explanation of what doesn't work - I don't count typing errors while following the instructions as something that needs to be fixed. The only thing that seems clear is that it does not seem to run in the IDLE editor. I have not done a lot of Python, nor have I done any GPIO stuff yet, but I got some bits of electronics at the weekend. I may have to check the exercise myself ;)

I will need to know which OS, and which versions of Python3, IDLE3 and the GPIO library are being used before reporting it (and anything else that might be significant). Might not get time to do this until the weekend though.

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

Re: Screaming jellybaby programming

Wed Jan 06, 2016 12:30 am

@choice.locks,
I'm not sure if you are following the other thread I was on with this issue. I got help and have seemingly solved the issue. See the last couple of thread here: viewtopic.php?p=877244#p877244 to see if it works for you.

Start python by this typing this into a terminal prompt:
sudo idle3

leave off the "&" that is in the worksheet. It finally all worked for me and the shell window did not freeze.

I was also going to help out with the info that Navys' requested but it was going to take me a few days to get to that.

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Wed Jan 06, 2016 6:56 am

Sorry folks but i am too busy to try your suggestions at present new year and all that but will do asap and report back.

choice.locks
Posts: 34
Joined: Fri Dec 25, 2015 8:51 pm

Re: Screaming jellybaby programming

Sat Jan 09, 2016 9:13 pm

RESULT for jelly baby burp
So here is the latest on getting the burping jelly baby to work
You can follow the suggestions given but no one has been able to resolve the sound file issue.
Re no sound comes out of the speaker. Only burp orinted on the screen.
We have yet to get a raspberry pi expert to post clear step by step instructions.
I have posted a clear step by step programming steps but no one has replied with a similar i got it working this way step by step answer.
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.

Return to “Beginners”