Autostart ScratchGPIO project

Sometimes it can be useful to make your Pi autorun something when it is switched on.

With ScratchGPIO, you can autorun a Scratch program (it doesn’t have to be one controlling the GPIO pins but ScratchGPIO is needed to make it autorun

There are 2 steps

Create Linux Script

Run LX Terminal

mkdir -p  /home/pi/.config/autostart

cd /home/pi/.config/autostart

nano scratchauto.sh

then type in following

cd /home/pi/scratchgpio5
sudo python scratchgpio_handler5.py &
scratch “/home/pi/Documents/Scratch Projects/autostart.sb”

If using ScratchGPIO6Alpha then do this instead

cd /opt/scratchgpio6alpha
sudo python scratchgpio_handler6.py &
scratch “/home/pi/Documents/Scratch Projects/autostart.sb”
CTRL-X then Y to save

chmod +x scratchauto.sh

Create a Scratch Autostart script

Make the Scratch script include the following in its On Green Flag Event

autostart

Then press the Green Flag to set AutoStart to True and save it in /homepi/Documents/Scratch Projects as autostart.sb

Reboot your Pi and it should automatically run the Scratch autostart.sb file

Simon

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 – broadcast 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