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
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
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
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
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?
Could you publish a link to a script that doesn’t work for me please?
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: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
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
File “/home/pi/sgh_GPIOController.py”, line 426, in pinUpdate
NameError: global name ‘GPIO’ is not defined
Maybe it runs only on Win machines.
Well? Is there any solution on this?
Sorry – missed your last post
LanPy is for Windows
It is a fork of my main ScratchGPIO project for the Pi.
So to send messages from a Pi – use ScratchGPIO 🙂
Strange thing is that Pi is “listening” well on Win messages with this.
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.
SID lets you remote into a Pi and control it from Scratch on a windows machine (only for ScratchGPIO5 at moment)
LanPy is for intended for sending messages between Scratch on Windows machines to save having to enable Scratch MESH – its very experiemental