Skip to Content

Scratch on the Raspberry Pi

« Teaching with Scratch
49 replies [Last post]
mark tranter
Member

Hi,

I am a teacher and a Raspberry Pi owner.

I wonder if any of you have seen the MagPi magazine - it had an article on Scratch (not by me) in thefirst issue.

I am planning to write something for the next issue. You can have a look at what I have so far here. (pdf).

It's very simple stuff. I am hoping to do more as I learn how to use Scratch more.

I'm probably going to focus on learning fairly traditional programming skills (as in the examples in the article) rather than making games and animations. I'll have to see what the editorial team on the MagPi think!

Anyway, if anyone has advice and feedback, I'd appreciate it.

mark

 

Replies
F. Gress
Member
I'm about to ask for Raspberry Pi & Arduino kits as a DonorsChoose project.
Anyone know if this particular kit (with "Raspbian") will be "WeDo-ready" out of the box?

I'll be back!
F. Gress
Member
So, I finally got the R-pi and have confirmed that the Raspbian distribution works with the LEGO WeDo system just fine.
Yay!
 
However, not so much luck with the laptops I tried.
Boo.
(I installed the Ubermix [Ubuntu] distro on 2 old-ish Dell Latitude D610's, and the WeDo USB connection does NOT seem to be working/recognized on either laptop. The special blocks do not appear in Scratch, nor does any sensor or motor work, even if I make the blocks appear by using the menu, then put them in a program. And yes, I tried all of the USB ports.)

I'd welcome any clues for trouble-shooting this -- or connections to folks who might know something abuut how/why the Raspbian distro DOES work with Scratch+WeDo.
I'll also post separately...
 
Mark Willis
Member
Looks a nice kit. Raspberry Pi only runs Scratch 1.4 which does support Wedo out of the box although I have only ever used it on a Windows machine and not the Raspberry Pi. So I'd expect it to work but am not 100% certain as haven't tried that.
Mark Willis
Member

I now have a raspberrypi! One thing that hasn't been mentioned here but is a topic on the raspberrypi forum is the performance of scratch on the raspberrypi or rather lack of. As it stands, its not a combination I could recommend. What are others thoughts?

mark tranter
Member

Hi Mark,

Sorry I haven't been on here and answered your posts. Glad to hear you have a Pi. As I guess you have seen if you go on the RPi forums, there is some discussion going on about the performance of Scratch. As far as I know, nothing major has been done yet. I did try to recompile Squeak from source, but I ran into a heap of problems and gave up. I will probably have another go at some point. But really it needs the Scratch developers to sort something out ...

Mark Willis
Member

That's ok. Not sure Scratch is the problem I think the VM needs some work and JITing it would be just what's needed. Started looking at it myself but its not within my skillset...at the moment!

Mark Willis
Member

Issue 4 of Magpi out now. Well done with the Frogger game.

mark tranter
Member

Thanks Mark, sorry I haven't replied until now. The October issue will feature a little Bubble Sort program. I have also been having fun with Scratch with my GCSE computing group - we've done a program to convert denary to binary, and one that does Hex.

Mark Willis
Member

Look forward to that. Have checked out the convertors and you need to add a test for negative numbers and fractions!

mark tranter
Member

Hi Mark,

Thanks for you feedback on the binary and hex converters. I don't think I know how to do that yet! I need to brush up on my understanding of two's complement and floating point numbers in binary!

mark

Mark Willis
Member

Was thinking more of defensive programming so detecting a negative number or fraction and asking user to re-enter a positive integer.

mark tranter
Member

Hi Mark - yes, I see what you mean. That would be sensible.

However, I want to tackle the more complex side of binary representation at some point.

I am teaching GCSE computing and I have been using Scratch to ease my Y11 students into programming.  Most of them had used it a bit to make animations etc, but not really to create more "traditional" programs.

Thanks for your comment!

Mark Willis
Member

Instead of drawing a frog, why not use  the 2 scratch cat sprites? Changing the costume makes it look like he's waliking. You can call it Scratcher instead of Frogger!

 

Well ordered the raspberry pi and now have to wait 11 weeks! So should get it for halloween!

mark tranter
Member

I just had a lesson with some Y8 students in which I showed them my frogger game and told them about the RPi foundation's competition. Then I let them choose to improve my game or make their own. I was impressed with what they did. I'm an English teacher so I don't often get the chance to do this. They had done some Scratching before, but I'm not sure how much. Anyway , most of them seemed to get the idea pretty quickly (quicker that I did!)

:)

mark tranter
Member

I just thought I'd give you a preview of what I am working on for next Month's Scratch Patch. Like I have said, I am a beginner. This is actually the first Scratch project I've made that uses animation and sound.

I would appreciate some feedback. On issue is that we are quite short of space in the Magazine (I only get 2 pages) so I will have to keep the project quite small.

Anyway ... it's a (simple!) version of Frogger:

 

EDIT - I've added some project notes. Thanks!

mark

Myra VanInwegen
Member

Just had a go with your Frogger. It's good! The sound effects are excellent. Just a few suggestions:

Arrow keys are easier to use than letter keys (maybe use left arrow for left, right arrow for right).

The frog sometimes ends up under the log rather than on top of it. Under looks there is a "go to front" block which would probably sort the program.

Maybe a better picture of a frog? But then I'm so not an artist that I feel I really have no right to complain about this!!

Anyway, it's nice. It's basic, but this is a good thing: it sets them thinking "hey, it would be better if..." and then they start to look into how they can make it better.

 

mark tranter
Member

Thanks Myra,

I'll change the keys. I'll have a look for that "go to front" block, I haven't used it before.

I have had a go a re-drawing the frog. I'm not much good at art ...

 

I do need to keep it simple as anything that looks much nicer would take up quite a bit more room in the magazine.

Although I have realised how to use a background instead of sprites for the "water" and "river-bank"!!

mark

Mark Willis
Member

Just downloaded to look at the scripts and yes you need to use the stage background and just have sprites for the logs and frog.

mark tranter
Member

Hi Mark, Yes, I realised that I should use a background. I had not got around to updating my Scratch file.

Like I said, I'm a beginner ...

 

Myra VanInwegen
Member

Breaking news! As of last night, I have got Lego WeDo working with the Raspberry Pi, with the help of Alex Bradbury. This is with the Debian wheezy SD card image. At the moment, wheezy is still in the testing phase with the Raspberry Pi, but feedback on it is so positive that after this weekend it's going to be the recommended distro. Alex (who's organizing the release of wheezy on the RPi) will incorporate the changes that allow WeDo to work into the Scratch that's included with the wheezy SD card image, so WeDo will work straight out of the box! Hooray!

 

mark tranter
Member

This is excellent news Myra.

I've mentioned the great stuff that the Scratch community are doing to the MagPi team. They are very impressed.

I've posted a link to something I am working on for next month's magazine, I'll repost it here.

If I can get my act together to do something that shows Scratch interacting with the outside world, I will definitely write about it in the magazine.

Frogger clone.

Mark Willis
Member

Excellent news. Things seem to be progressing at quite a pace. Feel rather out of the loop so maybe should order one.....

 

Have bitten the bullet and am in the queue, so no idea when I'll actually get it. Just wondering what they intend to do for schools as at the moment you can only order one per person?

Mark Willis
Member

Just seen your article in issue 3 of Magpi.

Well done!

mark tranter
Member

Thanks,

The good news is that the editorial team (I'm sort of on the fringe of it!) want me to do more on Scratch. I'll try to do something more fun next time.

 

Myra VanInwegen
Member

Hi Folks, we have too much indentation below, so I've clicked the Post Reply button rather than replying to a specific post.

Mark T wrote " I wonder if I could do something similar using the GPIO pins on the Raspberry Pi!"

The answer is, yes you can. You would need an analog to digital converter. I have been working on the Gertboard, and conveniently, it has exactly such a device. I could easily solder up something that would allow me to connect a thermistor to the A/D inputs of the the Gertboard. So then I could collect the data using a C program. And then the question is how to plot it... It has been a long time since I did anything graphical in C, does anyone by any chance have any suggestions for a good library to use to allow me to plot a graph similar to the one I made in Scratch? 

I know how to do graphics in Python (well... I'm learning Python, and I know where to look to find out how to do graphics in Python), and I have a Python GPIO module, so I could do it in Python... except that the Python GPIO module code doesn't drive the SPI bus, and the A/D chip uses the SPI bus... So I'd have to figure out how to do SPI in Python.

So I have to hand almost all the tools I need to duplicate this experiment on the Pi!

Ah, I've just thought of a way I could do it: I could collect the data using a C program, then put it into a file, then in Scratch I could read the data from the file into a list, then I could plot the data in the same way I plotted the data collected by the Picoboard! Then I could do the whole thing on the Raspberry Pi.

It would be more elegant to either (re)learn how to plot things in C, or how to drive the SPI bus in Python...

 

A Robinson
Member

We've slightly modified Scratch to allow it to use addon boards with the Raspberry Pi (through the SPI bus).  Using the PiFace board (http://piface.openlx.org.uk), we've also got interfaces for Scratch, Python and C http://pi.cs.man.ac.uk/interface.htm. Our idea is that people can mix and match and move between the languages as they learn more. We've got some local activities working with teachers developing worksheets, but when I saw this I wondered if people would be interested in some sort of online colaboration?

Mark Willis
Member

I run a computer club at my son's primary school and the lego wedo proved a hit. Using external hardware would certanly be of interest. I need to order an rpi for myself and see if I can get the school interested in using it too. Any collaboration could well be of interest.

mark tranter
Member

Yes, that would be a great idea. I am quite ignorant about Scratch and external devices (and I'm very much a beginner at Scratch anyway).

Please feel free to email me at:

antiloquax@sky.com

thanks,

mark

Myra VanInwegen
Member

Yes, this sounds like something I would be interested in. I've done a fair bit of work on the Gertboard so I'm familiar with the idea of using the GPIO to do things in the real world.

A Robinson
Member

There's a demo of it on youtube http://www.youtube.com/watch?v=OhaWDUAuajE including our emulator -- I'm looking at porting it to other boards like Gertboard.

 

Mark Willis
Member

Sounds great. Really like the thermistor stuff. Does the picoboard work with the raspbery pi?

P.S. Mark's card shuffling demo and your mention of recording sound gave me the inspiration to write a SNAP card game using the microphone in Scratch. Uploaded the project earlier today if interested! (Unlikely to be useful in a noisy classroom though)

Myra VanInwegen
Member

Embarassingly, I haven't yet tried the Picoboard with the RPi. .... OK, I just did! It works beautifully. Just plugged it in, and it works. This is using the new Debian Wheezy OS.

I haven't been able to make WeDo work with the RPi yet, but I do have some ideas I can pursue. I think that it's quite likely that I can make it work, with the help of my husband who is a systems and hardware expert.

mark tranter
Member

Wow - I am so impressed that you are using your Pi and Scratch like this!

I am not much of a hardware person ...

It'd be great to see more about these projects.

Do you have a blog, Myra - or maybe you could do an article for the MagPi?

 

mark

Myra VanInwegen
Member

Ha, too much indentation in my post below, you can't see my lovely melting ice graph! Here it is, unindented...

Myra VanInwegen
Member

I just joined ScratchEd. I'd been looking at it for awhile, but wanting to reply to Mark T's post was what finally spurred me to join. I was going to write exactly what Mark W said. The jist of the your MagPi article is kind of "how do you do traditional CS in Scratch". Now there is a place for that (I'll tell you about some ideas I've had in a minute) but for only the second Scrach article in the MagPi, I feel that it might be a bit on the dry side. Jaseman's Dizzy Cat / Crazy Drums in Issue 1 is much more in keeping with the ... Scratch ethos (for lack of a better word).

I've been giving some Scratch lessons in my daughter's Year 4 class. The lessons were as follows:

1. Intro to Scratch, sprites, scripts, costumes, the "say" and "change costumes" blocks. I created a tiny program where the cat says "I wish I was a dinosaur", then it changes into a dino courtesy of an imported sprite, then says "Hooray!" Then I got them to do their own thing.

2. Stroytelling with Scratch. How to use backgrounds, sound, motion, and "say" to tell stories. In this case it was a ghost story. The cat is in some dark woods, along comes a ghost with a scary noise, cat screams and runs away (well, "glides" away, we haven't done animation yet). The idea of this lesson was that you have 2 or more sprites, and you have to make sure that you put the code that you want the two different sprites to execute in the scripts for those different sprites. This is something that some of the kids in the first lesson were trying to do, but couldn't figure out. Again, they were let loose on the computers to do their own thing.

I have two more lessons planned, as follows:

3. Animation. I'm going to show them how to use the repeat loop, custume change, and more instrcutions to make a bat fly across the screen. My daughter has already started playing with this sort of thing at home, for example making people dance while playing cool music.

4. Question & answer, making choices. I'm going to show them a little program where the cat asks them where they want to go on holiday and how much money they have. If they have enough money then the background will change according to the holiday destination selected. Only here do they meet variables, user input, if'/then/else, and operators (<).

This is the sort of thing that I think makes a better intro to Scratch than how to do traditional CS things in Scratch.

Where the traditional CS things are really useful is in cross curricular activities, combining science and maths. For example, the Year 6s learn about some basic stats: mean, mode, median. Showing them how to implement this in Scratch is a good way to help them understand the stats themselves and how computers handle data. It's also cool to have real data that you yourself have harvested, for example using the Picoboard to record niose levels in your classroom. At least, I think... This is definitely an untested lesson plan!

mark tranter
Member

 Thanks Myra, for your detailed replies. It certainly sounds like you have some great ideas for teaching with Scratch.

Just to give a bit of context for my "article" (by the way, the latest draft is a bit different, but still probably rather dry. It does have a game on it now!), I am a teacher in a UK high-school. Most of the kids I teach (and I am an English teacher, not an ICT specialist!) already have some experience of Scratch and what they've done is mainly the making of stories, animations and games.

My agenda was always to use Scratch to explore basic programming ideas that might be useful to the students when they begin to learn Python (or whatever).

The MagPi is written by volunteers, so the content depends pretty much on the interests of the contributor. I agree that there are lots of things that one can do with Scratch that are more "Scratchy" than my scripts (and more fun).

I am stil a beginner at using Scratch. I'm sure the editorial team would be happy to publish material with a focus like the one you have taken, if you (or anyone else!) approached them.

The idea about environmental data / input sounds amazing, by the way.

I've certainly taken your comments on board. 

thanks 

mark

:)

Mark Willis
Member

Hi Mark,

I too am excited by the rpi but as yet just have it running in a virtual machine. For me the hardware add-ons will be key and would hope that things like Lego Wedo will be supported on the Scratch port for rpi.

I liked your examples very much however am worried that you want to focus on traditional programming skills using Scratch. I don't believe Scratch is the correct tool for that. For me the whole point of Scratch is the lack of a command line and focus on multimedia to ease and engage the learning process for children. I think a Scratch "Hello World!" program should be spinning and whirling coloured letters shooting around the screen accompanied by a fanfare of trumpets!

Good luck with the article,

Mark

mark tranter
Member

 Thanks Mark, for your comment.

I don't know anything about Lego Wedo, but the idea of connecting the Pi to external devices is certainly key. So far I've experimented a bit with the GPIO pins using LEDs and a switch, but that's all. 

I'm interested to read your comments on the article. As I said in reply to Myra (who made similar points), I do accept the criticism.

I know the team at the MagPi is keen to keep running articles on Scratch and this month I "stepped up" to offer some material. I'm not sure if the editors will want me to continue. If they do, I'll certainly try to make my next article more fun.

It's only fair for me to admit that one reason for the approach I took is my lack of experience as a Scratcher!

Thanks very much for your reply. I appreciate the time you've taken and the constructive criticism!

:)

mark

 

By the way, since you are running a virtual Pi, I am interested in which release you are using.

Mark Willis
Member

Hi Mark,

I think your article goes well with Alex's later article in issue 3. You've bravely given your email address in the article but I wondered if your racypy Scratch ID might be better as the projects could also be downloaded?

My intention was not to criticize but more as a warning. I develop software but have recently started a computer club at my son's primary school. They are very quick to see the possibilities when you show them Scratch can play sounds and the sprites move and animate. Having got that attention then adding in logic and loops to futher control things is much easier than the opposite direction which is; here is a loop, here is some logic etc..

Your article has given me some ideas. I think the dice simulator is crying out for 6 costumes representing each side of a die and that wonderful sound as dice bounce across a table top. That's why I didn't want to be negative as that is what the article should be doing.

As for my virtual Pi it was a virtual box ovi file from February so probably a bit dated.

Kind regards,

Mark

mark tranter
Member

Hi Mark, yes I was thinking about adding my Scratch ID - I just forgot to do that. I'll see if I can get that included before we publish. I don't think I have uploaded all the scripts I mentioned in the article yet. I will do that.

I'll have a go at what you suggest for the dice program.

Hope you are enjoying the RPi. It might be worth downloading the latest Arch release, if you have a chance. It runs faster than the Debian versions ;)

 

Mark Willis
Member

Scratch die roll

 

This makes quite a nice die roll. Just need 6 costumes  that look like each face. Just needs some sound and perhaps a bit more bouncing!

 

Note: Scratch can get addictive! I've created a project called dice roll that uses the above effects then plots the probablity distribution of the rolls. Find it under my Scratch user id drmcw if interested.

mark tranter
Member

Excellent! I'll have a look at your Scratch page! Yes, I do find Scratch strangely addictive ...

 

Myra VanInwegen
Member

Mark W, I love your die roll! Your project plotting the distribution of numbers you get from the die is exactly the sort of cross-curricular thing I was talking about... Nice link with maths there!

Here's a Scratch science project I've done for myself that would be really cool to do with some kids sometime... I grabbed a thermistor from the shed (doesn't everyone have a collection of electronics in their shed? -- my hubby does electronics for a living and occasionally as a hobby), froze it into an ice cube, attached it to one of the analog inputs of a Picoboard, then plotted the restistance (which corresponds roughly to the temperature). This is the resulting graph:

melting ice graph

The horizontal blue line is about 0C; the ticks along that line are the hours. I love this graph. It shows clear as can be that the temperature remains pretty much constant while the ice is melting, and only then once it's all melted does the termperature climb again, asympotically approaching room temp. Yes, you can do real science with Scratch!

mark tranter
Member

This is a really great idea. I wonder if I could do something similar using the GPIO pins on the Raspberry Pi!

mark

 

Mark Willis
Member

Agreed. Saw the post about the xbox kinect and Scratch which pointed me to the remote sensing protocol in Scratch. I'm sure that could be use ti access the GPIO pins with a small helper program. Might have to buy a rpi sooner rather than later. Would also  want to add a webcam with microphone. Have you tried any out to record pictures and sound in Scratch by any chance?

mark tranter
Member

Hi Mark, I hope you do get an RPi soon - sounds like you have some great ideas for it.

I don't know if anyone has done anything with recording audio on the Pi as yet - there's no analogue audio input (just a headphone jack).

I don't know what happens if you plug in USB microphone / headset.

These sorts of projects will certainly get the young people interested. :)

 

Carlos Caro
Member

Hi Mark,

Thank you so much for sharing this information. I'm looking forward to buy a Raspberry Pi this year; first time hearing about the MagPi Magazine so I started to download the two (2) available issues.

I think your focus it's unique and it's fair to have variety.

Awesome examples with comments included and of course the "Hello World!" was necessary!

Hope to see more coming.

Carlos.

Carlos Caro
Member

Hey Mark, bought my Raspberry Pi 2 days ago; just waiting to play with it!

mark tranter
Member

 Hi Carlos,

Thanks so much for your comment. The Scratch article has been changed quite a bit (we're looking to release Issue 3 at the weekend).

I am "racypy"  on the Scratch forum, if you want to see what I am up to!

mark