Some days I wished I had chosen the career of a carpenter. You still have problems to deal with, but at least as a carpenter you can beat the problem with a hammer. You may not be able to solve the problem that way, but it sure would help work out some of the frustrations.
I am working on a project to demonstrate some of the things you can do with a Raspberry Pi. I am doing this for our local library. One of the things I thought about building is a drum machine or a piano. The premise is when you touch a switch it causes the Raspberry Pi to play a sound. Very easily done in Python (the language I know best).
However, since this project is to target new users of the Raspberry Pi, I thought it would be nice to use the Scratch programming language. This is a visual programming language that is very powerful and really kid friendly.
The problem with using Scratch though is that it doesn’t natively handle the GPIO interface (General Purpose Input Output). These are 40 pins (or 26 on the older models) coming out of the Raspberry Pi that you can use to control hardware such as robots.
There is a project called ScratchGPIO that gives me the control I need. However, I had a problem with playing sound out of the computer when using the GPIO pins. Each time I would make the program play a sound, Scratch would exit (force quit). Looking through several forum threads did not turn up a solution quickly.
Finally, I found a forum post that gave an answer that solved the problem for me. I wanted to include it here in case it may be a help to others (and because I will probably forget the answer the next time I need it). Hopefully no one will have to dig as long as I did to find a solution.
The steps below assume that you have already read the instructions for getting the program installed. It is also probably a good idea to run the basic first program. Having said that, you probably wouldn’t have come here unless you already had the program up and running and fell into the same problem I had with sound.
- Start the ScratchGPIO program. When you install it, it will place an icon right on your desktop. Just double click the icon.
- After it is loaded, simply close it.
- Open a terminal window. I do this by typing “alt+F2” that will open a start program box. Inside that box type “lxterminal” and hit enter. Don’t actually type any of the quotation marks in this step.
- Inside the terminal window type “/usr/bin/scratch.old &” then hit enter. Again, no quotes.
- Scratch will re-open. Go to File | Open and select the “rsc” program (which is installed when you install ScratchGPIO).
That should make it so you can now use sound in your programs when using the GPIO interface.
I really don’t know if all those steps are necessary. I know I have opened a program I was working on in step 5 without opening the rsc program. It worked fine without doing that final step.
I would think that some of this can be automated with a script if someone wants to try and think that through. For me, the steps aren’t too cumbersome.
This is another one of the many things I have written up so that I can find the answer for myself when I need it in the future. I hope it is a help to others.
Buy a Raspberry Pi
If you don’t have a Raspberry Pi, head on over to MCM Electronics and buy one from the official US distributor.
A friend of mine asked me about the new Raspberry Pi 2 and what I thought of it. This isn’t intended to be an in-depth explanation of the differences between the old and the new models. But, in summary, I would like to buy one of the new ones for myself. It is 6X faster than the current model B+, runs all the same software and is in the same form factor. There is no reason to buy a B+ at this point unless they drop the price considerably to get rid of old stock.
My Current Stable of Raspberry Pi
I personally own a Raspberry Pi Model B (original) and a Model A+. I also bought a Model B+ and an A+ for the office.
My Model B (which I bought in the summer of 2013) is used at the house as a web, SSH and VPN server. I also use it to do Python programming. I am not much of a programmer, but when I have taken classes, I did all my homework on the Raspberry Pi through SSH. The web server that I am running with it (which is publicly accessible, but I am not wanting to promote it) is really just to do some basic PHP scripting that my son and I were testing. The VPN server is not used as much as it should be. But, basically this machine has found a permanent home and isn’t easily available for playing around with.
My Model A+ was purchased in December of 2014 and is used for play. Eventually it will be the brains behind a laser engraver that I have been working on. I have all the electronic brains built and working. What I don’t have done is the X/Y motor system. I have all the parts, I just haven’t built it yet. The A+ will power that when I finally get it done. Until then, I have enjoyed having it as an extra toy.
At the office the A+ is in service as a power monitor. It is connected to a UPS and collects info on the line voltage and when the power flickers or stays out for any length of time. I expect that it will just hang out there for a few years before it needs to be used for anything else.
The B+ was supposed to live its life as a video camera for recording and live streaming events at our training center. But, it hasn’t been working out the way I planned. So right now it is used for playing around with the Raspberry Pi camera module on whatever projects I can make up that still looks like I am doing important work.
To Buy Next
I think the Raspberry Pi B+ for the office will end up not being used in any valuable way there, so I will probably buy it off them and find a use for it at home.
I would like a Raspberry Pi 2 B. I just need to find a justifiable use for it. An RPi 2 could take the role of one of my minor servers. Then, if it does well, I may put a few other things on it. Nothing super important to start with. We have an internal instant messaging server that could easily run on a current model. Other small, relatively unimportant, services like this would be great to have running on a piece of hardware that takes almost no electricity compared to a full Linux server.
Where to Buy
MCM Electronics is the source to buy from. They are the official distributor in the US and the only place I know where you get the actual price of $35 that is always advertised. Currently they have the B+ on sale for $30.
Here is a comparison between the new and the old Model B+ (RPi2 B vs RPi B+). At about 1:20 the speed test starts.
Fatal error: Uncaught Error: Call to a member function id() on array in /homepages/23/d164530573/htdocs/mts/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php:36 Stack trace: #0 /homepages/23/d164530573/htdocs/mts/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php(538): CrayonFormatter::format_code('', Array, Object(CrayonHighlighter)) #1 [internal function]: CrayonFormatter::delim_to_internal(Array) #2 /homepages/23/d164530573/htdocs/mts/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php(516): preg_replace_callback('#()#msi', 'CrayonFormatter...', '#!/bin/bash\r\nif...') #3 /homepages/23/d164530573/htdocs/mts/wp-content/plugins/crayon-syntax-highlighter/crayon_highlighter.class.php(166): CrayonFormatter::format_mixed_code('#!/bin/bash\r\nif...', Object(CrayonLang), Object(CrayonHighlighter)) #4 /homepages/23/d164530573/htdocs/mts/wp-content/plugins/crayon-syntax-highlighter/crayon_highlighter.class.php(186): CrayonHighlighter->process() #5 /homepages/23/d1645 in /homepages/23/d164530573/htdocs/mts/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 36