element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum GPIO on scratch
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 25 replies
  • Subscribers 707 subscribers
  • Views 3644 views
  • Users 0 members are here
  • raspberry_pi
Related

GPIO on scratch

tabarus12
tabarus12 over 13 years ago

Hi does anyone know where I can download and how to install control for GPIO on the weeze scratch?

Its so much fun to use scratch but its kinda limited to visual efect only, Id like to use it for comunication with the outside world.

  • Sign in to reply
  • Cancel
Parents
  • ntrayler
    ntrayler over 13 years ago

    A lot of useful work has been done by cymplecy (a teacher in the uk) into using Scratch on the Raspberry Pi to control the GPIO. Follow his instructions and you should be up and running fairly quickly.

     

    http://cymplecy.wordpress.com/2013/04/22/scratch-gpio-version-2-introduction-for-beginners/

     

    Make sure that you have updated to the latest version of Raspbian (sudo apt-get update; sudo apt-get upgrade) as Scratch has been patched to improve performance and to fix some annoying bugs that were present in the earlier versions.

     

    Scratch 2.0 is not particularly useful as it doesn't run on the pi (its a web based application) and it cant access the GPIO.

     

    Hope this helps.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • tabarus12
    tabarus12 over 13 years ago in reply to ntrayler

    I checked this out and I cant seem to install it it shows file or path not found or sintax error when I try the sudo /boot/install instruction like the page describes.

    Do you know how to download it correctly because the instructions on the page arent working.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ntrayler
    ntrayler over 13 years ago in reply to e14 Contributor

    Hi Marcelo,

     

    That message means that the desktop shortcut cannot find  the shell script that should have been created in the directory /home/pi/simplesi_scratch_handler .

     

    In a LX Terminal window go to the directory where install_scratch_gpio2.sh is located. this will either be in /boot  if you used the wget command or in /home/pi if you downloaded the file using Midori. then run the command:

     

    sudo ./install_scratch_gpio2.sh

     

    Watch the output and check if there are any errors if there are then make a note of them and let me know.

     

    If there are none shown then try clicking again on the ScratchGPIO2 icon.

     

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to ntrayler

    Hi Neil,

    again failed.

    I reinstalled as you said.

    My install_scratch_gpio2.sh is at /home/pi/

    Then I tried with sudo ./install_scratch_gpio2.sh and appears this:

     

    Self Extracting Installer

     

    ./blikll.py

    ./blinkll.sb

    ./GPIOexample.sb

    ./installer.sh

    ./rsc.sb

    ./scratchgpio2.desktop

    ./scratch_gpio_handler2.py

    Running Installer

     

    Install Details:

    Home Directory: /home/pi

    User: pi

    Group: pi

     

    Finished.

     

    Then, when execute the icon on the desktop said the same.

    Failed to execute child process "./simplesi_scratch_handler/scratch_gpio2.sh" (No such file or directory).

    Thanks in advance, Marcelo.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ntrayler
    ntrayler over 13 years ago in reply to e14 Contributor

    Hi Marcelo,

     

    Ok so the installer thinks it has completed with no errors.

     

    Is there a sub-directory called simplesi_scratch_handler in your /home/pi directory ? if it does exist, does it contain two files scratch_gpio2.sh and scratch_gpio_handler2.py ?

     

    If the two files are there then try using LX Terminal to run the scratch_gpio2.sh script directly:

     

    cd /home/pi/simplesi_scratch_handler

     

    ./scratch_gpio2.sh

     

    This should open the scratch window. If not do you get any error messages ?

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to ntrayler

    Hello Neil,

    good, now is working, and Scratch opens OK, but.........

    I looking for HELP menu, and then in ABOUT SCRATCH.

    What about that?? Why appear as Scratch 1.4??

    image

     

    Thanks,

    Marcelo

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    Why appear as Scratch 1.4?

     

    Version 1.4 is correct.  The next version is 2.0, which is available to use online,

    rather than as a download.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ntrayler
    ntrayler over 13 years ago in reply to e14 Contributor

    Hi Marcelo,

     

    I am glad it is now working for you.

     

    As coder27 said scratch 1.4 is the current version for the non web based version. Version 2.0

     

    This is the second version of Simon's (Cymplesy) scratch GPIO handler hence the scratch_gpio2.sh. filename. For tutorials etc see http://cymplecy.wordpress.com/2013/04/22/scratch-gpio-version-2-introduction-for-beginners/

     

    Have fun.

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to ntrayler

    Hello,

    I am new to the raspberry Pi, and I am getting frustrated... Anyway, I am stuck with

    chmod /home/pi/install_scratch_gpio2.sh    

     

    When I tried the previous command, it says:   chmod: missing operand after   /home/pi/install_scratch_gpio2.sh

     

    Please help.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    chmod changes the permissions on a file.  You have told it which file, but not what permissions you want to apply.

     

     

    You probably want to make the file eXecutable, so that it can be run as a program.

     

    So

    chmod +x /home/pi/install_scratch_gpio2.sh

     

    The manual pages are your friends.  Try "man chmod" for all you ever wanted to know about the chmod command, (or any other command).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    Thank for for your response.... Still nothing...

     

    I tried

    chmod +x /home/pi/install_scratch_gpio2.sh

     

    and I got:

     

    chmod: changing permissions of `/home/pi/install_scratch_gpio2.sh' : Operation not permitted

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    ok , that suggests that the user running the command (pi?) does not own the file.

     

    try

    ls -l /home/pi/install_scratch_gpio2.sh

     

    The output will contain, amongst other things, the name and group of the owner.  You might expect it to be "pi pi".  I suspect that it wil be "root root".

    (Looking back over this thread, the file was fetched using "sudo wget..." so will belong to root. That "sudo" isn't really necessary)

     

    So now you have 2 options:

    1) change the owner to pi with "sudo chown pi:pi /home/pi/install_scratch_gpio2.sh", then retry the chmod.

    or

    2) run the chmod command as the root user "sudo chmod +x /home/pi/install_scratch_gpio2.sh"


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    ok , that suggests that the user running the command (pi?) does not own the file.

     

    try

    ls -l /home/pi/install_scratch_gpio2.sh

     

    The output will contain, amongst other things, the name and group of the owner.  You might expect it to be "pi pi".  I suspect that it wil be "root root".

    (Looking back over this thread, the file was fetched using "sudo wget..." so will belong to root. That "sudo" isn't really necessary)

     

    So now you have 2 options:

    1) change the owner to pi with "sudo chown pi:pi /home/pi/install_scratch_gpio2.sh", then retry the chmod.

    or

    2) run the chmod command as the root user "sudo chmod +x /home/pi/install_scratch_gpio2.sh"


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    You were right...  It was root root

     

    I changed the ownership to pi (I doubled check it with the file manager)

     

    When I entered   " ls " the file changed to yellow

     

    but it doesn't install when I try to run   sudo /boot/install_scratch_gpio2.sh 

     

    I am feeling awful for asking so many questions sorry...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    but it doesn't install when I try to run   sudo /boot/install_scratch_gpio2.sh

     

    What's the error message you're getting?

     

    Did you download install_scratch_gpio2.sh into /boot or /home/pi?

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    It is working now...!    I had to run it from the /home/pi

     

    THANKS!

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    Guys... Please, what am I doing wrong?    It indicates an indentation error - line 7

     

     

    import time

    import RPi.GPIO as GPIO

    GPIO.cleanup()

    GPIO.setmode(GPIO.BOARD)

    GPIO.setup(7,GPIO.OUT)

    while True:

    GPIO.output(7,GPIO.HIGH)

        time.sleep(1)

    GPIO.output(7,GPIO.LOW)

        time.sleep(1)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    You need to indent the line(s) following a "while" loop to show

    which lines are part of the loop.  So instead of:

     

    while True:

    GPIO.output(7,GPIO.HIGH)

        time.sleep(1)

    GPIO.output(7,GPIO.LOW)

        time.sleep(1)

     

    you probably want:

    while True:

        GPIO.output(7,GPIO.HIGH)

        time.sleep(1)

        GPIO.output(7,GPIO.LOW)

        time.sleep(1)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to e14 Contributor

    Thank you!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube