Scratch 1.4 Messaging on Windows Computers for Schools

My ScratchGPIO for the Raspberry Pi can send messages between 2 computers so I’ve made a version that runs on Windows so that two windows PCs running Scratch 1.4 can send messages between themselves or to from a Pi

Its all alpha level at moment but if anyone fancies playing with it here is some rough instructions

On 1st PC

Install Python 2.7

Download these 2 files and save them in a folder

https://www.dropbox.com/s/dogc6qt4u058kt9/LanPy.py?dl=0

https://www.dropbox.com/s/g6arcetcnk1pk7w/sgh_GPIOController.py?dl=0

Run the LanPy.py program

Open up Scratch 1.4 and enable Remote Sensor Connections (or just open this file)

If you don’t know the IP of the computer use

GetIp

and then look at ipaddr sensor to find out what it is

On the 2nd PC – do exactly the same

then make up 2 blocks

When I recieve hello
say Hello for 2 secs

Then on 1st PC

broadcast linka.b.c.d

where a.b.c.d is the ip address of the other computer

then you can

broadcast send hello

and the 2nd PC should say hello

Simon

You may also like...

8 Responses

  1. Mike says:

    Hello,

    nice one. I tried that and sent messages from a Win machine to an R-Pi. But i could not do the opposite. The python code hit some errors when i run it on R-Pi. Can it be corrected?

    • cymplecy says:

      Could you publish a link to a script that doesn’t work for me please?

      Simon

      • Mike says:

        Yes, it is your LanPy.py
        It gives some strange output when i run it on my Pi:

        DEBUG:root:Change or triger detected in pin:40 changed to:0, trigger val:0
        DEBUG:root:datalen: 106
        DEBUG:root:RAW: fsensor-update “pin7” 1 “pin8” 1 “pin10” 1 “pin19” 1 “pin21” 1 “pin22” 1 “pin23” 1 “pin24” 0 “pin26” 0
        DEBUG:root:dataList: [‘sensor-update “pin7” 1 “pin8” 1 “pin10” 1 “pin19” 1 “pin21” 1 “pin22” 1 “pin23” 1 “pin24” 0 “pin26” 0’]
        Exception in thread Thread-1:
        Traceback (most recent call last):
        File “/usr/lib/python2.7/threading.py”, line 552, in __bootstrap_inner
        self.run()
        File “LanPy.py”, line 2700, in run
        self.vPinCheck() # check for any pin On/Off/High/Low/1/0 any PWM settings using power or motor
        File “LanPy.py”, line 984, in vPinCheck
        sghGC.pinUpdate(pin,self.valueNumeric)
        File “/home/pi/sgh_GPIOController.py”, line 426, in pinUpdate
        GPIO.setup(pin,GPIO.OUT)
        NameError: global name ‘GPIO’ is not defined

        Maybe it runs only on Win machines.

  2. Alex Dane says:

    Hi Simon,

    For a schoolproject I am working with a team on a project to teach the kids some basic programming skills. The idea I had was that the kids will be developing a program on a Windows desktop with Scratch. We also have bought a 4tronix Initio robot car and the idea is to send the commands from the Scratch from the Windows desktop with a Python script to a Python script on the Robotcar. The Python script on the robot car would then directly control the Gpio.

    Would that be possible and could the above mentioned Lanpy.py and sigh_GPIOcontroller.py be of any help with this step?

    Many thanks in advance.

    Alex Dane

    • cymplecy says:

      SID lets you remote into a Pi and control it from Scratch on a windows machine (only for ScratchGPIO5 at moment)

      http://simplesi.net/sidrpi/

      LanPy is for intended for sending messages between Scratch on Windows machines to save having to enable Scratch MESH – its very experiemental

      Simon

Leave a Reply to cymplecy Cancel reply

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