Scratch2GPIO

Raspberry Pi have worked with MIT to produce a Scratch2 compatible program that runs standalone on a Pi3 or Pi2 (but not older models or PiZero series).

It comes with basic gpio pin control but I’ve modified this, with help from David Ferguson (@fergusondavid6 ) and Nicole Parrot (@Cleo_QC)   so that it can take advantage of all the features of ScratchGPIO.

The code is considered beta at moment  and block syntax might change so only use it for testing out at moment and to inform discussion on what extra features we can add in with the extra ability of Scratch2 at our disposal 🙂

Grateful thanks to Sarah Lacase (@slmediation) and Darren Townsend (@forrishilier) for testing out the code and finding the bugs 🙂

Installing

With Raspberry Pi connected to Internet

1st of all – make sure your Pi is either up-to-date or your using a 21st Jun 2017 image or later.

Just check that Scratch2 is installed in the programming menu – if not, just do a sudo apt-get install scratch2 from a LX terminal window.

Copy the text below ( left click just before the s of sudo and drag right until all the text in the line as been selected) then right-click and select copy. Open up an LX Terminal window and select Edit and the Paste that into an LX Terminal window and press Enter it to download the installer.

wget https://git.io/vQsDn -O isgh8dev.sh

Once the installer has been downloaded then just type (or copy and paste the text below as before)

sudo bash isgh8dev.sh

 

and press Enter

 

The installer will create 3 desktop icons – the new Scratch2GPIO 8DevPlus one and ScratchGPIO8dev and ScratchGPIO 8DevPlus which is used with a lot of add-on boards.

Using it

Double-click the new Scratch2GPIO 8DevPlus icon and wait till it all loads up.

Click on More Blocks – Add an Extension – select Pi GPIO and click OK.

You should now have a new set of blocks to use that uses (as far as possible) the same syntax as the original ScratchGPIO running on Scratch 1.4

Main differences are

  • The black broadcast blocks should be used to send commands and not the orange control ones
  • You have to send variable changes off to ScratchGPIO yourself as Scratch2 isn’t as clever as its older sibling 🙂 So instead of old method of just changing a variable value e.g:
    set MotorA to 50
    you now would still create a variable called MotorA but to get ScratchGPIO to use its value you’d have to do this
    set MotorA to 50 (using red data block)
    set MotorA to MotorA (using black block where first MotorA would be plain text and second MotorA would be the red variable block)(I really need to get some images into this explanation 🙂

The syntax and the type/number of blocks might change so please do not use it to build a long-term project yet 🙂

Ideas and suggestions (and bug reports) VERY welcomed 🙂

Contact me via posting comment on this post or twitter @cymplecy or email simplecy@googlemail.com

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *