I haven’t done much with my Raspberry Pi yet. Judging from what a lot of people have been saying I’m not the only one. I was planning on taking it to a workshop at an Institute of Physics event in Liverpool, but due to the renovation of the host computer labs rendering them unavailable that particular workshop was cancelled.
One thing I did do with the Pi was set it up. This was a little problematic because I’ve borrowed a lab monitor which has integrated speakers and takes a HDMI feed for the visual stuff and a 3.5mm jack for audio. The result was no sound because the Pi assumed that if I’m using HDMI at all then that’s where it should be sending the sound to. Once I figured out how to change that, which involved the installing of some new drivers and the creation of some entries in a start up configuration file I found that Scratch (software for helping kids to learn to code visually) still didn’t have sound. Other things now seemed to be playing sound fine, but not Scratch.
After a while I stumbled upon a file that I assume is run when you run Scratch. I *think* it’s written in smalltalk. I have absolutely no experience with smalltalk, and although this sort of venture, messing with setup files that you don’t understand, is not advised and I don’t really know what I was doing the outcome was that I managed to make the Scratch cat meow. I made sure that I kept a good record of the changes I made, which boiled down to commenting out a bit of code that looks like it sets up sound, and replacing it with my own code.
This sort of fumbling around in the dark hacking took me back to the days of my childhood, when games ran in DOS and you had to write bat files to configure the memory before they would load. I didn’t really know what I was doing then either. I just knew that if I wanted to play X-Wing I needed to type in these commands, and then later – that if I wanted to play X-Wing faster in future I could save these commands as a file and call them all at once.
Anyway, I shared my solution, together with a disclaimer advising against using it, on the Raspberry Pi forum where so far it seems to have been of use to a few others who posted replies, and probably a few more who didn’t.
In between marking I’ve been taking the odd look at my raspberry pi, which you can now see sporting a swanky laser cut transparent acrylic case.
Laser cut pi case – I took this with the gourmet food setting on my camera!
I managed to connect it to the network and get it through the proxy without too much trouble. My next issue though was sound. There didn’t appear to be any! In my setup I’m connecting the HDMI cable to a monitor, but using the 3mm audio jack for sound. I reasoned that perhaps there is sound, but it’s just getting sent to the wrong place. A few google searches later and I’d found out how to set the thing up so that it automatically sends the sound to the audio jack, even if there is a HDMI cable connected.
Messing around with a linux operating system reminds me a lot of when I got my first PC and had to mess around in DOS to get anything to work. It’s interesting rediscovering this feeling of optimistic intrigue. A feeling of “I know I can make this do what I want it to; the question is how?”.
I still had an issue though. Scratch still didn’t appear to want to play sounds. After a little more digging I found out that when Scratch is run it runs in a smalltalk vm which is set up using a script (presumeably written in small talk) that I could edit. Now, I’m not familiar with linux, or with smalltalk, but I had a bit of a hack with the code whilst carefully leaving breadcrumbs should I want to undo my changes and I think I’ve figured out how to make Scratch do the same think.
In any case, the cat meows now!
Yesterday I had the pleasure of giving a group of upper and lower sixth students from Cottingham High School
a session on Scratch. Scratch is a visual programming environment to give people a gentle introduction to programming.
Pong – this game is clearly heading to be an epic battle!
In Scratch you can create sprites from image files and then give them scripts by dragging around code elements that fit together like jigsaw pieces. If you’re a programmer you can probably figure out what the code below is doing. In fact, you could probably figure it out even if you’re not a programmer.
A script in Scratch
I was a little worried that what I had prepared was too much to get through, but the students did really well, even though my print outs were black and white and scratch relies heavily on colour. If you want to play my simple pong game you can find it here. You might have to download some plugins though.
Towards the end of the session I was asked to talk a little about the sorts of things we do on our university courses. I talked for a couple of minutes and there seemed to be a genuine interest – but nothing made the students faces light up more than when I talked to them about three thing game. Apparently the idea of getting in a load of pizza and staying up all night coding is very appealing.