Better external Python calls from ScratchGPIO8dev

I’ve improved calling external Python scripts from ScratchGPIO8dev to allow for long time running programs.

This allows you to make your own mini sensor script to get some data from somewhere – your own sensors or from an Internet source and feed the values back into Scratch as sensor values.

 

I’m using this technique for my ISS Tracker Robot Arm project

To start data sensing I call this block

0

which calls this Python Script

http://pastebin.com/5LPpMwy2

to send ISS Altitude, Direction and Distance into my Scratch script

Note:

ScratchGPIO only handles one such process per program at the moment do don’t try and call 2 running processes.

Behind the scenes, ScratchGPIO will attempt to kill any previous launched external script but if you change the name of your script then you yourself should manually kill the old process

You may also like...

4 Responses

  1. Raf says:

    Hi,
    is there a way to get data back from a python script to scratch? I don’t see an option to read a file or so in Scratch itself…

    thanks!
    Raf
    ps: great work! 🙂

  2. Raf Cox says:

    ok, thanks! I’ll have a look.

    Fyi, I’ve bought a sensorkit from joy-it (sensorkit.joy-it.net; all in german so you might need google translate). Most of their examples are in Python… But this way, it should be easier to access it from Scratch…

    Raf

    • cymplecy says:

      A lot of those modules will work directly with Nuscratch/ScratchGPIO directly – leds and switches for example – only need to write own python code for some of the specialist items

      No need to re-invent the wheel 🙂

Leave a Reply

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