ScratchGPIO development Version

Here is the latest development version of ScratchGPIO for testing


wget -O


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

sudo bash

New Features

piconzeroSupport for 4Tronix PiConZero board ic digital,pwm and servo outputs and neopixels

Calling external programs

broadcast run python

will run an external program (in the /home/pi folder) called

Improved H-Bridge motor control

Just find out which 2 pins control your H-Bridge motor and create a variable to control its speed from -100 to 100

e.g PZM motor Shim uses the pins 35/37 and 36/38  so just create 2 variables




You may also like...

40 Responses

  1. Hello,
    thanks a lot for your work ! I’m a french STEM teacher, and after playing with the arduino I tried the Rapsberry.
    First I tried it with the PiFace shield, it works fine. This is cool for domotic but when I tried to build a robot with it I had a problem : motor can’t roll back !
    So I bought a PiRoCon card, it’s just perfect ! And with ScratchGPIO it’s easier and I’m trying to show it to primary teacher.
    But your ScratchGPIOv4 doesn”t work with the PiRoCon, whereas the v3 works fine…

    I try to build (it’s just the very beginning) a wiki about my test to help teacher, newbies, use it with pupills :

    Thanks a lot !

    • cymplecy says:

      Hello – thanks for the bug report – V4 should work OK now – please try it again 🙂


      • Thanks…but I still have the same problem after installation : “./scratchgpio4/” not found… You have to write Exec=/home/pi/scratchgpio instead of Exec=./scratchgpio

        It seems the handlet doesn’t work…no initialisation of the PiRoCon…ScratchGPIO3 work perfectly.

        Thanks a lot.

        • cymplecy says:

          I don’t understand why you have to change the Exec line – it is in excatly the same format as the scratchgpio3 shortcut which works for you 🙁

          Can you re-download the latest version as I’ve found one bug that would stop it working on some systems.
          Can you try running from LX terminal
          cd /home/pi/scratchgpio4

          it should launch the handler in a window and then Scratch – you shoudl either see an error or eventually if will say Running


      • The Exec line on the v3 isn’t “./scratchgpio/…” but “/home/pi/….” ; I don’t remember if I changed something or if it’s the original one.
        Your script “works”, but it seems to never stop on the LX terminal…
        However, ScratchGPIO4 works fine with PiRoCon !!! Perfect !

        I now have to make documentation and test sonar…

        Thanks a lot !

  2. Hi Simon.
    I’m using a new GPIO board called the Pibrella at the moment. Is it fairly easy to specify a new AddOn definition, or is that something you need to do?

  3. Dear Santa Claus,
    I use the PiFace on my Rapsberry and the PiRoCon, could you please include the PiFace handler inside an unified hanlder ?

    Thanks a lot !

    • cymplecy says:

      unfortunately, I don’t have a PiFace 🙁

      My code was originally the PiFace code but I changed it to just simply control the GPIO pins and then I ended up adding support fro add-on boards in.

      Maybe one day the PiFace fairies will lend me one 🙂


  4. Alan Hughes says:


    I’ve installed V6 as described above; however, upon running ScratchGPIO6alpha I don’t appear to have any control over the GPIO pins (this based on attempting to configuring a pin as output and subsequently issuing a broadcast to set the pin on). Looking at the pins at the command line (gpio readall) indicate that all pins are still set to input. The exact same steps in ScratchGPIO5 works as expected.

    Could the issue be related to the fact I’m running a B+?


    • cymplecy says:

      Not sure what you mean by atempting to configure a pin as an output as just say pinx on will turn it on – no configuration is needed 🙂 Also no idea what gpio readall is/does 🙂 But anyway – I’ll power up my B+ and have a check – what pin are you trying to turn on?


  5. Alan Hughes says:

    Working with Pin11. After firing up scratch V6 I would run the gpio utility (which is part of wiringPi) to look at pin status. It will tell you if pins are configured for input, output or both along with the current state of the pin.

    Anyway, part of the problem is I didn’t have smbus installed. Just figured out the location of the so I can start it up from the command line and see any errors. The script seems to be working ok until it hits pin 29. I’m getting the following output from the script:

    setting pin 29 to in with pull up
    error reading pin event 29
    The channel sent is invalid on a Raspberry Pi

    at which point it just grinds (loops) on pins 29 thru 40.

    Within Scratch I have crated a variable “Pin11” and can set it to 1 or 0 but there is no voltage change on pin11 itself. I also attempted to broadcast “Pin11high” and “Pin11low” with no luck.

    I’m also getting an exception thrown in thread Thread-1:
    it looks like it’s coming from line 310 of based on the Traceback. The exception ValueError is “The channel sent is invalid on a Raspberry Pi”


  6. uk_baz says:

    Hello Simon,

    I’m having a play with your ScratchGPIO6 and the Pi2go-lite. I’m up and running using the variable AddOn set to pi2golite .
    The motors are running and the front and back LEDs are working fine.
    From the sensors I’ve got the values from the left and right IR sensors in ‘if’ statements. Although it is slightly confusing (as when the left and right LEDs turn on the value is ‘off’ in Scratch) they are working.

    I’m now trying to use ‘when I receive Triggerpin23’ to do something when the button is pressed on the robot. This doesn’t seem to be working.
    Any suggestions on how I can debug this?


    • cymplecy says:

      I’ve just been changing my trigger code recently so I’ll power it up on a Pi2GoLite and see what’s happening

      BTW you are the very first person to mention using the new Trigger stuff in V6 🙂

    • cymplecy says:

      Well, I’ve looked into the code and its got into a bit of a shambles!!!!!

      I’m charging my batteries and let you know when I’ve got it back into shape (I was playing with wheel encoders and obviously mucked things about too much)


    • cymplecy says:

      Please try installing the ScratchGPIO6Dev version

      The sensors should report on when LEDs are on – the linefollowers should show up and the switch should produce TriggerSwitch events


  7. Alex Dane says:

    Last weekend I have installed ScratchGPIO 6 and Scratch interface Device on my Raspberry pi which is part of a 4Tronix Initio Ultimate robot. When I have only the motors connected to the Pirocon board, it works without problem. When I connect the IR obstacle sensors tot pin 7 and 11, the Scratch GPIO python scripts hangs on the following line GPIO.setup(pin,GPIO.IN,pull_up_down=GPIO.PUD_UP)

    Any suggestions?

    • cymplecy says:

      Hi Could I ask you to just detail what steps you are going thru to reach the hanging stage?

      email me on simplecy at googlemail dot com


  8. Glenn Wiebe says:

    Thank you for this new release! My Scratch was crashing after every GPIO off command. Now with v7 I don’t have any problem taking pins up and down! Thanks.

  9. Patrik says:

    I bought the Unicorn Hat for a workshop with kids next week but with Scratch its freezing again and again. I am using Scratch7 with a Pi3. Any knowledgea about that? Would be great if you could help me.

    • cymplecy says:

      UNicorn hat needs a lot of power – Pi3 needs a lot of power – so I’d think it was a combination of both of them together.
      Turn brightness right down to test – I mean a value of 1 or 2

  10. Patrik says:

    The display of the unicorn freezes and then I have to restart scratch.

  11. Patrik says:

    Also I dont know how to display images on scratch to the hat.

  12. Patrick says:

    Thank you! Right now I am working with the sense hat and now it is crashing immediately when I am opening scratch in all projects. Additionally. Where do I have to place images if I want to load them?

  13. Patrick says:

    I Feel like I need to reinstall everything. I didn’t think about the energy issue. Maybe I played around too much with trouble shooting and this IC7 script.

  14. Patrick says:

    Even If I load the sense hat example scratch crashes immediately . Sense Hat should be fine as it works with Python.

  15. Patrick says:

    I already debugged several times, problem occurs with all scratchgpios on my rp3. Last week before using unicorn hat everything was fine with sense hat . Simple LEDS with breadboard work.

  16. Patrick says:

    I found a Little Solution . I have to delete the unicorn addon and create s new Add on again … Now I just Need to figure Out how to display pictures 🙂

  17. Patrick says:

    Well not Really . Its crashing again

    • cymplecy says:

      Feeling your pain a bit here
      I think NuScratch supports the sensehat natively (or have I got that wrong?)
      Can you try that out first (i.e don’t use ScratchGPIO)

      I can’t find my unicornhat at moment as in the middle of refurbishing the playroom so everything is piled up in another room 🙁

  18. Raghu says:

    I am also facing same issue. When we set the Addon to SenseHAT and run the scratch crashes. Tried loading the gpio-scratch example and that also crashes scratch. Please help asap. Thanks

  19. Ashish says:

    I was trying out Scratch GPIOv8 for receiving a sensor value in python and changing the brightness of an led according to that in Scratch . Using it I am able to send broadcast from python to scratch, but i am not able to start the python program using the following command- ‘broadcast run python’ .Nothing happens when i send this broadcast in Scratch. Also, when i am receiving a variable broadcast from python i.e. a value from some sensor which keeps changing, how do i monitor that in scratch without knowing what to look for.

    • cymplecy says:

      This feature is new so prob a bug in my code
      Could you send me yoru Scratch and your python scripts to test out at my end please?


Leave a Reply to uk_baz Cancel reply

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