Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

How to configure Scratch GPIO- (Part 1/12)

By Prabakaran P.M

Scratch is a programming tool for creating embedded games,stories and animations without using any written codings, rather using visually organized syntax which is in blocks with a drag-and-drop interface. One can use these blocks according to one’s requirement, scratch’s control of hardware is not only limited to the external inputs such as the keyboard and mouse.This article explains how to configure Scratch to extend its power to access GPIO(General Purpose Input and Output) of the Raspberry Pi.


In this tutorial a Raspberrypi board is booted with Ubuntu OS and is connected to the Ethernet port of a Windows7 PC. The board is connected to the internet as explained in the article Connecting the Raspberry pi to the internet. The IP address of the Raspberrypi board has been obtained to remote login in the TUI using the PUTTY and is remotely accessed using VNC.

Open terminal and type the following command:

wget http://bit.ly/1wxrqdp -O isgh7.sh

The file will be downloaded and saved in the SD card.

Dowloading Scratch Command for Raspberry pi

Fig. 2: Dowloading Scratch Command For Raspberry Pi

Or download the file directly to another computer and copy it to your Raspberry Pi Shared folder.

Execute the File to install Scratch GPIO by use of the following command:

bash isgh7.sh

If not logged as the root user, add the sudo before the command like:

sudo bash isgh7.sh

and press Enter

This will install all the necessary extra software and some examples.

Installing Scratch and other softwares

Fig. 3: Installing Scratch And Other Softwares

This installation will create two desktop icons – ScratchGPIO7 is used for beginners for simple circuits and ScratchGPIO 7Plus is used by experts with a lot of add-on boards.

How it works:

Scratch can also shout called “broadcast” to anything which is called as listening and also hear called “receive” any other things which are shouting too.

The python program called “scratch_gpio_handler.py” will runs in the background and it is set up to listen any of these broadcast messages and turn them into GPIO actions.

The current scratch_gpio_handler.py has the GPIO pins fixed to the following inputs and outputs. The pin numbers given, are the pins as counted on the P1 GPIO header itself.

Broadcast Commands:

Outputs (21,18,16,15,13,12,11)

Command

Alt Command

Result

pinXon

pinXhigh

Turns pin X ON

pinXoff

pinXlow

Turns pin X OFF

allon

allhigh

Turns all pins ON

alloff

allow

Turns all pins OFF

pinpattern1010111

Sets each pin ON or OFF depending on 1 or 0 [21,18,16,15,13,12,11]

Making led blink:

Making led blink using scratch

Fig. 4: Making Led Blink Using Scratch

The green flag in the play window is to start the code, here we have used forever loop block to make the led blink forever.

Sensing inputs:

Inputs (26,24,22,19,10,7)

Sensing inputs in Scratch to access GPIO

Fig. 5: Sensing Inputs In Scratch To Access GPIO

In scratch separate sensing block is available where sensor value consists of a slider which includes the input pins can be used accordingly. We can use this variable block to compare with binary values using control blocks.

Controlling of LED using buttons:

Controlling of four led using four switches is visually coded here and working is demonstrated in the video.

Controlling LED using buttons

Fig. 7: Controlling LED Using Buttons

Circuit Diagrams

Circuit-Diagram-Configure-Scratch-GPIO

Project Video


Filed Under: More Editor's Picks, Raspberry pi, Tutorials

 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What is a loop calibrator? 
  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • What was before microcontrollers ?
  • 74HC595 creating Fake output
  • NEED HELP FOR OP-AMP IN BGR
  • Check undesired substrate mode...
  • Cap extraction of an IC PAD

RSS Electro-Tech-Online.com Discussions

  • Question about ultrasonic mist maker
  • Best way to reduce voltage in higher wattage system?
  • Two 300nH inductor in series, can get higher current?
  • Someone please explain how this BMS board is supposed to work?
  • What is "off the shelf values for inductors"?
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering