ScratchGPIO5 launched

I’ve made ScratchGPIO5 the “stable” version and it’s available here

The main fundamental change is to go back to early philosophy and set pins 11,12,13,15,16 and 18 as outputs and all other pins as inputs with internal pull-up resistors enabled.

This makes it very easy for beginners on a budget to get going using breadboards as switches just have to be wired between pins and 0V to produce input changes.

ScratchGPIO 5 Plus icon launches exactly the same program as ScratchGPIO 5 but all pins are set as inputs with no pull-ups enabled.

This should satisfy both beginners and advanced Scratchers who don’t want their home fusion setup to scram the reactor when the program launches 🙂

Any comments and suggested improvements and bug reports always welcome either here or on twitter @cymplecy

 

You may also like...

47 Responses

  1. Great news !!! Thanks a lot for all your work, I’ll try it as soon as as possible.

  2. Everything works fine ! No problem with PiRoCon shield.
    Thanks for your work !

  3. tubluv56@gmail.com says:

    Hi Simon, Following a very successful introduction of Scratch 4 to my grandson, I see there is now version 5 available. Do I have to remove version 4 before installing version 5 or can I just do “apt-get update” Thanks Alan

    TTFN Alan

  4. rbn2013 says:

    Hi just loaded version 5 and tried it with PiRingo programs. The one below works perfectly on scratchgpio4 but on version 5 spurious leds light at the wrong time.
    http://r.newman.ch/rpi/problemonScratchgpio5.png
    any ideas why?

  5. rbn2013 says:

    Further to last post the problem is that Set Led11On turns on Led 1 as well.

  6. rbn2013 says:

    Thanks. I can confirm that the problem is fixed in the 5dev version.

  7. Jezz says:

    Hi, is there any support for the RPi Camera module with Scratch5 .
    Thanks in advance.

  8. Jezz says:

    Be interesting to see how you get on with that and be great if it was possible.

  9. Hi, I’ve just installed ScratchGPIOv5 to use with the PiBrella and I’m loving it. One small problem I’ve found is that I’m using the inputs A to C as switches for a wire buzzer game, i.e. where you move the loop from start to finish without making the buzzer sound. The problem is if the loop touches the wire very briefly then scratch doesn’t always detect the input even though the built-in LED on the PiBrella triggers. Is there some way to buffer the inputs in your addon so that they could be read say, for up to a few hundred millsecs after they’ve triggered as I suspect Scratch is busy doing something else and so misses the very short input. Thanks.

  10. alistair mann says:

    hi
    i have installed gpio5 and it has given me the two new icons on the desktop but when i open them it is still 1.4 ?

    • cymplecy says:

      Its all fine – don’t worry 🙂

      What ScratchGPIO icons do is simultaneously launch Scratch (1.4) and a background program that lets Scratch talk to the GPIO pins.

      Does that make sense?

      Simon

  11. Anne Carlill says:

    Hi, Am loving learning how to use Scratch GPIO with Pibrella. It’s two steps forward and one step back but at least I’m making progress. Anyway thanks for providing Scratch GPIO 🙂

  12. Peter Johnson says:

    Hi, love scratch gpio. Using itvfrim Y5 to Y8, but I’m having an issue when using motors. Often, when one script has been created controlling a motor, subsequent scripts won’t work as if the pi is still trying to run the first script. Any suggestions? Thanks.

  13. Peter Johnson says:

    Didn’t explain this well, sorry. Should gave explained that I meant it was subsequent new projects that didn’t seem to work, not new scripts in the same program.

    • cymplecy says:

      Have you got 2 sequential scripts you could post that don’t work for you?

    • cymplecy says:

      Can you post 2 scripts that won’t work sequentially please
      Workaround would be to close Scratch and relaunch ScratchGPIO again in-between 2 projects but lets see if I can find a better solution
      Simon

  14. Michael grobe says:

    Hi: my python script to blink LEDs on pins 18 and 24 work but the test script with scratchgpio5 doesn’t work even when modified to broadcast allon. Oh. I’m running on a brand new Kano.

    Ideas?

    • cymplecy says:

      Hi
      ScratchGPIO only defaults 11,12,13,15,16 and 18 as outputs so pin 24 won’t respond to the allon command
      But 18 should of course.

      I haven’t tried ScratchGPIO out on a Kano for a while so I’ll try downloading it and making sure ScratchGPIO still works with it

      Simon
      Just checking – you know that ScratchGPIO uses physical pin numbers not the broadcom ones?

    • cymplecy says:

      Well – to get it working on Kano involves quite a few hoops I’m afraid.
      The basic issue is that the Desktop doesn’t work the same way as a normal Raspberry Pi.
      So, an icon to launch ScratchGPIO doesn’t get created.
      And Kano doesn’t use the same default Pi user as a Raspberry Pi
      So you need to find out what user name you are using (I used si when I setup my Kano)
      Go into Terminal and use this to install instead of website instructions
      sudo bash isgh5.sh si (replace si with your Kano username)
      This just needs to be done once – you should get a message saying its been done OK

      Then, each time you want to use it ,open up Scratch and load in project rsc.

      Run Terminal and type the following.
      cd scratchgpio5
      sudo python scratchgpio_handler5.py

      You should see a load of struff scroll up with the word connected towards the top of the screen.
      minimise the terminal window and you now effectively have ScratchGPIO5 running

      Simon

  15. Michael grobe says:

    Simon: Thank you greatly for your reply. I followed your instructions almost as you gave them. However Isgh5.sh won’t run til i

    makedir Directory

    In my home directory /home/michael.

    At which point when i run …handler5.py i get

    PWM/Servo NOT imported OK
    ADC/DAC NOT imported OK
    Minecraft imported OK
    Board Revision 2
    Debug enabled
    2
    PiGlow init
    i2cbus: 1

    … Lines omitted

    Starting to connect… Trying
    There was an error connecting to scratch!
    I couldn’t find a Mesh session at host: 127.0.0.1, port: 42001
    Trying.
    . . .

    Many more failed connection attempts with this same message.

    So there seems to be a problem with Mesh or perhaps my execution of your instructions or the experimentation i had already tried.

    Thanks, Michael

  16. Michael grobe says:

    But wait! I started a new instance of scratch, opened rsc, reran the handler, opened the test routines modified for pin 18 where necessary and possible, and viola’. We have liftoff!

    Now i see that i have to run the handler after i run scratch and open rsc. Note: open rather than import.

    Superb! Thanks again.
    Michael

  17. John says:

    Greetings, I can’t get Scratchgpio5 (or 5plus) to change the state of GPIO pins. Running the script from command line sudo python motortest.py works fine. pin12 is enable pin on 754410 quad H-Bridge. Pin 16 is signal A on H-Bridge. Pin 18 is signal B pin oh H-Bridge. Running from Scratchgpio I tried setting varibles pin12=on, pin12off etc. Tried braodcast pin12on / broadcast pin16on / broadcast pin180ff. No go. When using variable method (pin either on or off) and displaying variables on stage, I see the variables changing along with the wait commands in script. Even putting a Voltmeter between ground and a pin in the script shows no change in pin states. Reinstalled scratchgpio5. Same problem. Even simple thing as turning an LED on/off according to the example on your website does not work. ALSO tried running scratchgpio as ROOT. No cigar…. Any clue(s) to what I’m doing wrong? My grand kids enjoy Scratch very much and are waiting for me to resolve this so they can do things in the real world. Thanks !!!

    • cymplecy says:

      Reboot
      go into a terminal session
      cd scratchgpio5
      sudo python scratchgpio_handler5.py

      this should run the python handler that interfaces SCratch to the GPIO pins

      You should get a message about Scratch trying to connect.

      You can then run NORMAL Scratch and open file rsc – this enables Scratch to talk to the handler – go back to the window and see if it now says connected

      Simon

      • John says:

        Thank you so much for the speedy reply! I did as you said and get the following error repeating:
        There was an error connecting to Scratch!
        I couldn’t find a mesh session at host 127.0.0.1, port: 42001.

      • John says:

        Also did a netstat — listen and verified that no other application has TCP 42001.

      • John says:

        Here is the entire output. Sorry to be such a pest.
        pi@raspberrypi1 ~/scratchgpio5 $ sudo python scratchgpio_handler5.py
        PWM/Servo imported OK
        ADC/DAC imported OK
        Minecraft imported OK
        Board Revision 2
        Debug enabled
        2
        PiGlow init
        i2cbus: 1
        self.bus:
        0 1 2 3 4 5 6 7 8 9 a b c d e f
        00: — — — — — — — — — — — — —
        10: — — — — — — — — — — — — — — — —
        20: — — — — — — — — — — — — — — — —
        30: — — — — — — — — — — — — — — — —
        40: — — — — — — — — — — — — — — — —
        50: — — — — — — — — — — — — — — — —
        60: — — — — — — — — — — — — — — — —
        70: — — — — — — — —
        No PiGlow Detected
        No Compass Detected

        Error accessing device at address 0x40
        No PWM/Servo Board PCA9685 detected
        init PCF8591
        No ADC/DAC PCF8591 Detected
        No AdaMatrix Detected
        No PiMatrix Detected
        pi camera init
        starting at 0

        PATH: /home/pi/scratchgpio5
        Starting to connect… Trying
        There was an error connecting to Scratch!
        I couldn’t find a Mesh session at host: 127.0.0.1, port: 42001
        Trying
        There was an error connecting to Scratch!
        I couldn’t find a Mesh session at host: 127.0.0.1, port: 42001
        Trying
        There was an error connecting to Scratch!
        I couldn’t find a Mesh session at host: 127.0.0.1, port: 42001
        cTrying
        There was an error connecting to Scratch!
        I couldn’t find a Mesh session at host: 127.0.0.1, port: 42001
        ^CTraceback (most recent call last):
        File “scratchgpio_handler5.py”, line 3122, in
        the_socket = create_socket(host, PORT)
        File “scratchgpio_handler5.py”, line 2918, in create_socket
        time.sleep(3)
        KeyboardInterrupt

      • John says:

        Please accept my apology. It CONNECTED now. Now that I followed the rest of your instructions… So now NORMAL Scratch is running, the dialog box saying remote sensors are active came up. Still in normal Scratch I open the motortest program and the pins still do not respond. When I close normal scratch and open Scratchgpio5 the connection error is still there. I’m lost.

        • cymplecy says:

          So I’m assuming that when you run Scratch and open up rsc – the handler connects OK

          When you close Scratch – the handler disconnects (as you’d expect)

          So assuming that when you run Scratch and open rsc we are back to connected state.

          given this is true – it is almost 100% certain this will work
          broadcast pin11on
          wait 1 broadcast
          pin11off

          so just need to check – are you using real pin numbers or broadcom gpio numbers? ScrratchGPIO uses real pin numbers

          Simon

          • John says:

            You are correct sir. I also notice there are lines of debug showing pins being reset (in terminal window) at the same time the dialogue box “Remote Sensors Are Enabled” Appears. — I’m using physical board numbering not the Broadcom MCU numbers. The example did not work – maybe because I don’t understand “wait 1 braodcast”. I see the wait 1. But wait 1 broadcast is not an option… An anomoly is, when I reload Scratch, the pins seem to go to the state before closing scratch…. No need to ruin your Friday evening – I’ll keep at it looking for other clues and will post back findings.. Thank you Simon. You’ve got me on the right track for sure.

          • John says:

            Simon, It’s working. I have to stay in NORMAL Scratch. Also found I have to stop the sketch/script/recipe when all pins are in low state or the motor keeps running even after scratch program is closed. I can close the Scratch software but not the terminal where the handler5.py is running – restart Normal Scratch and run the rsc program. Motor works again. Repeated this several times. Will not work with ScratchGPIO5.. Is there a way to run the rsc program automatically with normal scratch? You’ll prolly see this next week. Thanks again sir, and the best of weekends to you!

          • John says:

            I found the AutoStart instructions. Thank you!

  18. Gavin says:

    Hi,

    I am building a project with my daughter (loving how easy ScratchGPIO is to use) and need to remove the “Remote Sensor enabled” dialogue so the program can autostart. Although a little out of date I found the right code in system browser from http://www.penguintutor.com/news/raspberrypi/scratchautostart
    However when remove the “if true….” line I get the following error on save:

    MessageNotUnderstood: UndefinedObject>>position

    Can you point me in the right direction….or even better is this dialogue removed in a newer version?

    Thanks in advance

    Gavin

Leave a Reply

Your e-mail address will not be published. Required fields are marked *