Tag Archives: Scratch

Scratching Vinyl Straddles Physical and Digital Realms

via Hackaday » hardware

The life of a modern DJ is hard. [Gergely] loves his apps, but the MIDI controller that works with the app feels wrong when he’s scratching, and the best physical interfaces for scratching only work with their dedicated machines. [Gergely]’s blog documents his adventures in building an interface to drive his iPad apps from a physical turntable. But be warned, there’s a lot here and your best bet is to start at the beginning of the blog (scroll down) and work your way up. Or just let us guide you through it.

In one of his earliest posts he lays out his ideal solution: a black box that interprets time-code vinyl records and emulates the MIDI output of the sub-par MIDI controller. Sounds easy, right? [Gergely] gets the MIDI side working fairly early on, because it’s comparatively simple to sniff USB traffic and emulate it. So now he’s got control over the MIDI-driven app, and the hard part of interfacing with the real world began.

After experimenting a lot with timecode vinyl, [Gergely] gives up on that and looks for an easier alternative. He also considers using an optical mouse, but that turns out to be a dead-end as well. Finally, [Gergely] settled on using a Tascam TT-M1, which is basically an optical encoder that sits on top of the record, and that makes the microcontroller’s job a lot easier. You can see the result in the video below the break.

And then in a surprise ending worthy of M. Night (“I see dead people”) Shyamalan  he pulls timecode vinyl out of the grave, builds up a small hardware translator, and gets his original plan working. But we have the feeling that he’s not done yet: he also made a 3D printed optical-mouse holder.

We can’t wait to see more from [Gergely], and wouldn’t mind seeing some of the code behind this project either. In the mean time if all this leaves you feeling inspired to make your own DJ controls entirely from scratch, have a look at this completely DIY turntable project.

Filed under: ARM, hardware, musical hacks

A new version of Scratch for Raspberry Pi: now with added GPIO

via Raspberry Pi

There are many excellent things to be found in last week’s release of Raspbian Jessie and we’ve been keeping one of the best ones tucked under our big Raspberry Pi-shaped hat. In the Programming menu on the desktop you’ll find a new version of Scratch, our favourite programming language for beginners.

Breadboard and Scratch on Raspberry Pi

Connect buttons, sensors, cameras, LEDS, goblin sticks and other gubbins to your Pi using Scratch

Tim Rowledge, who has been “vigorously wrangling Scratch into shape over the last couple of years” (thanks Eben), tells us what’s new:


Along with the new Raspbian release we are including the latest Scratch system update. It might have seemed a bit quiet on the Scratch front since March, but lots has happened here in the rainforests of Vancouver Island. There are two primary changes you will notice:

  • a significant increase in speed
  • the addition of a built-in GPIO server.

Speedier Scratch

One of the big projects last year was to modernize the Scratch code to run in a current Squeak Smalltalk system rather than the very old original version; this improved performance a fair bit all on its own, since the newer Squeak benefited from a lot of work over the years. [The Scratch world is created using Squeak, a dialect of the Smalltalk programming language, and Squeak itself runs on a software emulation of a computer system called a virtual machine -Ed.] It also built us a Scratch that could run on the very latest Squeak virtual machines that have dynamic code translation, generating machine code at run-time. Along with work to improve the Squeak code that implements Scratch, we then had a noticeably faster system.

A major project this year has been building such a virtual machine for the Pi; until now, only x86 machines have been able to run this version. With a very generous amount of support from Eliot Miranda – the original author of the Cog virtual machine and all-round software deity – the ARM Cog VM has been whirring away since around June.

Benchmarks are always a nastily slippery subject, but we feel that Squeak performance is typically between 3 and 10 times faster, obviously depending on what exactly one is measuring. Things will get even faster in the future as we iron out wrinkles in the code generation, and soon we hope to start benefiting from another project that does code optimization on the fly; early hints suggest at least a doubling of performance. Since Scratch uses a lot of graphics and UI code it doesn’t always speed up so much; but we already did a lot of graphics speed improvements for prior releases.

Our favourite “scary big demo” is Andrew Oliver’s implementation of Pac-Man. The original release of Scratch on the Raspberry Pi Model B could manage almost one frame per second, at best. The same Model B with the latest Scratch system can manage about 12-15 frames per second, and on a Raspberry Pi 2 we can get a bit over 30, making a very playable Pac-Man.


The new GPIO server for Pi Scratch is a first pass at a new and hopefully simpler way for users to connect Scratch to the Raspberry Pi’s GPIO pins or to add-on boards plugged into them. It is modelled on the mesh/network server and uses the same internal API so that either or both can be used at any time – indeed, you can have both working and use a Pi as a sort of GPIO server or data source. We have not introduced any new blocks at this point.

The server also allows access to the Pi camera, IP address and date and time and allows complex functionality. For example, the following scripts (along with a suitably configured breadboard) provide the ability to turn LEDs on and off according to a button, to take a photo with a countdown provided by a progressively brightening LED, and ways to check the time etc.

Examples of using Scratch to control the camera module, control LEDs connected to the Raspberry Pi's GPIO pins, and check the time

Examples of using Scratch to control the camera module, control LEDs connected to the Raspberry Pi’s GPIO pins, and check the time

Add-On Hardware

We can also plug in Pi add-on cards such as the Sense HAT, Pibrella, Explorer HAT, PiFace, PiLite and Ryanteck motor board.

Each card has its own set of commands layered on top of the basic GPIO facilities described above.

Demo project scripts

In the Scratch Examples directory (found via the File-->Open dialogue and then the Examples shortcut) you will find a Sensors and Motors directory; several new GPIO scripts are included, including the one above.


Closing notes from Clive

We’re really pleased that GPIO is now built in to the Pi version of Scratch. It means that users can use access the GPIO pins “out of the box,” and so get into physical computing that much more easily. We’ve also introduced the GPIO pin numbering system also known as BCM numbering for consistency across our resources, and having our own version of GPIO support gives us finer control over functionality and support for add-on boards in future.

All of our resources using Scratch will use this version from now on, and existing resources will be rewritten. Tim’s reference guide details all of the commands and functionality, and there will be a simplified beginner’s tutorial along this week.

Last of all, there’s no way I can end this post without taking the opportunity to thank our community who have supported (and continue to support) GPIO in Scratch on the Pi. In particular, a big thanks to Simon Walters, aka @cymplecy, for all of his work on Scratch GPIO over the last few years.

The post A new version of Scratch for Raspberry Pi: now with added GPIO appeared first on Raspberry Pi.